This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fix issue in the simplification of pow() with nested exp{,2}()

Authored by evandro on Aug 23 2018, 3:57 PM.

Diff Detail


Event Timeline

evandro created this revision.Aug 23 2018, 3:57 PM

It isn't obvious why this case is different than the other transforms, so some code comments are needed.

  1. We can't rely on dead code elimination because libcalls may not be readnone (ie, they may set errno).
  2. The calling code in LibCallSimplifier and InstCombine handles erasing the called function itself in all cases.
  3. In this transform, we're potentially eliminating the intermediate exp2 call, so we have to manually kill it.

But what happens if the exp2 call has another use besides the pow call? We need a test for that scenario.

The function pow_exp2_libcall() in the test case is one such example without readnone. I'll augment the test case with a reuse scenario.

evandro updated this revision to Diff 162751.Aug 27 2018, 2:43 PM

Address the case when the result from exp{,2}() is reused elsewhere.

spatel accepted this revision.Aug 27 2018, 2:52 PM


This revision is now accepted and ready to land.Aug 27 2018, 2:52 PM
This revision was automatically updated to reflect the committed changes.