This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Fold fcmp with dominating assume
Needs ReviewPublic

Authored by cppio on Aug 4 2022, 7:23 AM.

Details

Reviewers
nikic
spatel
Summary

Fold float comparisons like x >= y after assume(x > y). This treats fcmp like icmp, which already has this optimization.

Diff Detail

Event Timeline

cppio created this revision.Aug 4 2022, 7:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 7:23 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
cppio requested review of this revision.Aug 4 2022, 7:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 7:23 AM
nikic added a reviewer: spatel.Aug 5 2022, 8:17 AM
nikic added a subscriber: spatel.

@spatel seems to be doing work in this area right now...

spatel added a comment.Aug 5 2022, 9:37 AM

This looks right. I made some cosmetic changes to this code in the last day (hopefully easier to read), so you'll need to rebase/update.

Please add the new tests with baseline (current) output to D131168. That way, we'll show the diffs in this patch.

It would be good to confirm that everything checks out with Alive2 as well. I don't know of any programmatic way to cycle through the predicates, but you can verify by pasting in the before/after IR for these (and possibly more) tests:
https://alive2.llvm.org/ce/z/5EEWrF

llvm/lib/Analysis/ValueTracking.cpp
6761

Shorten:

if (auto *LHSCmp = dyn_cast<CmpInst>(LHS))
  return isImplied...
6784

Similar to above: use "auto *" here to reduce code.