[PATCH] D141481: [SCEV] Canonicalize ext(min/max(x, y)) to min/max(ext(x), ext(y))

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 04:42:36 PST 2023


mkazantsev created this revision.
mkazantsev added reviewers: fhahn, nikic, reames, lebedev.ri.
Herald added subscribers: StephenFan, javed.absar, hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

I stumbled over this when trying to improve our exit count work. These expressions
are equivalent for complementary signed/unsigned ext and min/max (including umin_seq),
but they are not canonicalized and SCEV cannot recognize them as the same.

The benefit of this canonicalization is that SCEV can prove some new equivalences which
it coudln't prove because of different forms. There is 1 test where trip count seems pessimized,
I could not directly figure out why, but it just seems an unrelated issue that we can fix.
Other changes seem neutral to me.


https://reviews.llvm.org/D141481

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/ext_min_max.ll
  llvm/test/Analysis/ScalarEvolution/fold.ll
  llvm/test/Analysis/ScalarEvolution/logical-operations.ll
  llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info-rewrite-expressions.ll
  llvm/test/Analysis/ScalarEvolution/ptrtoint.ll
  llvm/test/Analysis/ScalarEvolution/range_nw_flag.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141481.488155.patch
Type: text/x-patch
Size: 19679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230111/9e849876/attachment-0001.bin>


More information about the llvm-commits mailing list