This is an archive of the discontinued LLVM Phabricator instance.

[CodeGenPrepare] Avoid sinking soft-FP comparisons
ClosedPublic

Authored by whitequark on Apr 3 2016, 8:12 AM.

Details

Summary

Sinking comparisons in CGP can undo the job of hoisting them done
earlier by LICM, and soft-FP makes this an expensive mistake.

A common pattern that produces floating point comparisons uniform
over a loop is an explicit check for division by zero. If the divisor
is hoisted out of the loop, the comparison can also be, but hoisting
the function that unwinds is never legal, since it may cause side
effects in the loop body prior to the unwinding to not be executed.

The test is not inherently x86-specific, but it requires a way to set TargetLowering.useSoftFloat() from the command line, and x86 is the easiest way to ensure that.

Diff Detail

Repository
rL LLVM

Event Timeline

whitequark updated this revision to Diff 52503.Apr 3 2016, 8:12 AM
whitequark retitled this revision from to [CodeGenPrepare] Avoid sinking soft-FP comparisons.
whitequark updated this object.
whitequark added a reviewer: bkramer.
whitequark set the repository for this revision to rL LLVM.
whitequark updated this object.
whitequark added a subscriber: llvm-commits.
bkramer accepted this revision.Apr 3 2016, 9:38 AM
bkramer edited edge metadata.

Looks fine to me.

This revision is now accepted and ready to land.Apr 3 2016, 9:38 AM
This revision was automatically updated to reflect the committed changes.