This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] fold fcmp (minnum, X, C1), C2
ClosedPublic

Authored by spatel on May 8 2019, 12:14 PM.

Details

Summary

This pattern showed up when I was investigating a different minnum optimization. I can add the maxnum sibling as a follow-up if this looks ok.

We should be able to perform some other combines when the constants are equal or greater-than too, but that would go in instcombine if I'm seeing it correctly.

Diff Detail

Event Timeline

spatel created this revision.May 8 2019, 12:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 8 2019, 12:14 PM
nikic added a subscriber: nikic.May 11 2019, 2:26 AM
nikic accepted this revision.May 15 2019, 7:49 AM

LGTM. In the future, it might be nice to generalize this as a getConstFloatRange() function (that would be [-INF, C] for minnum and [C, INF] for maxnum) and fold the comparison based on that.

This revision is now accepted and ready to land.May 15 2019, 7:49 AM
cameron.mcinally accepted this revision.May 15 2019, 8:12 AM

Corner cases look good, so LGTM.

llvm/lib/Analysis/InstructionSimplify.cpp
3463

Looks like bracket doesn't line up with switch.

spatel marked 2 inline comments as done.May 15 2019, 9:39 AM
spatel added inline comments.
llvm/lib/Analysis/InstructionSimplify.cpp
3463

Oops - will fix before committing.

This revision was automatically updated to reflect the committed changes.
spatel marked an inline comment as done.