Page MenuHomePhabricator

[InstCombine] Split the FP constant code out of lookThroughFPExtensions and use nullptr as a sentinel.
ClosedPublic

Authored by craig.topper on Feb 27 2018, 2:29 PM.

Details

Summary

[InstCombine] Split the FP constant shrinking code out of lookThroughFPExtensions and turn it into a helper function that returns nullptr on failure.

Currently this code's control flow very much assumes that there are no meaningful checks after determining that it's a ConstantFP. So whenever it wants to stop it just does "return V".

This patch just moves all the code into a helper function and returns nullptr when it wants to stop.

I've split this from D43774 while I try to figure out how to best handle the vector case there. But this change by itself at least seemed like a readability improvement.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Feb 27 2018, 2:29 PM
spatel accepted this revision.Feb 27 2018, 3:54 PM

LGTM.

lib/Transforms/InstCombine/InstCombineCasts.cpp
1442–1443 ↗(On Diff #136158)

Since we're going to fix this: a loop is unnecessary here AFAIK. isEliminableCastPair() would always squash those?

This revision is now accepted and ready to land.Feb 27 2018, 3:54 PM
This revision was automatically updated to reflect the committed changes.