Page MenuHomePhabricator

[InstCombine] For pow(x, +/-0.5), stop falling into pow(x, 1.5), etc. case

Authored by hubert.reinterpretcast on Mon, Sep 21, 9:06 PM.



The current code for handling pow(x, y) where y is an integer plus 0.5 is not explicitly guarded against attempting to transform the case where abs(y) is exactly 0.5.

The latter case is meant to be handled by replacePowWithSqrt. Indeed, if the pow(x, integer+0.5) case proceeds past a certain point, it will hit an assertion by attempting to form pow(x, 0) using getPow.

This patch adds an explicit check to prevent attempting the pow(x, integer+0.5) transformation on pow(x, +/-0.5) as suggested during the review of D87877. This has the effect of retaining the shrinking of pow to powf when the sqrt libcall cannot be formed.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMon, Sep 21, 9:06 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
hubert.reinterpretcast requested review of this revision.Mon, Sep 21, 9:06 PM
spatel accepted this revision.Tue, Sep 22, 6:15 AM



That looks like another bug. We formed an extra sqrtf() call from a not-quite-dead pow() call?

This revision is now accepted and ready to land.Tue, Sep 22, 6:15 AM

I'm not sure I'll be able to chase this one. Do you have a recommendation on how to mark/track it?

spatel added inline comments.Tue, Sep 22, 6:46 AM

A 'FIXME' comment in the test file should be ok. Bonus points for filing a bugzilla. :)

This revision was landed with ongoing or failed builds.Tue, Sep 22, 11:23 AM
This revision was automatically updated to reflect the committed changes.