[all-commits] [llvm/llvm-project] 137630: [InstCombine] Canonicalize range test idiom
Nikita Popov via All-commits
all-commits at lists.llvm.org
Mon Nov 8 12:16:02 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1376301c87274bccf5565eb892173442782b1de3
https://github.com/llvm/llvm-project/commit/1376301c87274bccf5565eb892173442782b1de3
Author: Nikita Popov <nikita.ppv at gmail.com>
Date: 2021-11-08 (Mon, 08 Nov 2021)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
M llvm/test/CodeGen/BPF/adjust-opt-icmp1.ll
M llvm/test/CodeGen/BPF/adjust-opt-icmp2.ll
M llvm/test/Transforms/InstCombine/2006-12-15-Range-Test.ll
M llvm/test/Transforms/InstCombine/2007-03-21-SignedRangeTest.ll
M llvm/test/Transforms/InstCombine/2008-08-05-And.ll
M llvm/test/Transforms/InstCombine/and-or-icmps.ll
M llvm/test/Transforms/InstCombine/canonicalize-signed-truncation-check.ll
M llvm/test/Transforms/InstCombine/icmp-add.ll
M llvm/test/Transforms/InstCombine/icmp-sub.ll
M llvm/test/Transforms/InstCombine/icmp-topbitssame.ll
M llvm/test/Transforms/InstCombine/load-cmp.ll
M llvm/test/Transforms/InstCombine/minmax-fold.ll
M llvm/test/Transforms/InstCombine/or.ll
M llvm/test/Transforms/InstCombine/overflow.ll
M llvm/test/Transforms/InstCombine/smulo.ll
Log Message:
-----------
[InstCombine] Canonicalize range test idiom
InstCombine converts range tests of the form (X > C1 && X < C2) or
(X < C1 || X > C2) into checks of the form (X + C3 < C4) or
(X + C3 > C4). It is possible to express all range tests in either
of these forms (with different choices of constants), but currently
neither of them is considered canonical. We may have equivalent
range tests using either ult or ugt.
This proposes to canonicalize all range tests to use ult. An
alternative would be to canonicalize to either ult or ugt depending
on the specific constants involved -- e.g. in practice we currently
generate ult for && style ranges and ugt for || style ranges when
going through the insertRangeTest() helper. In fact, the "clamp like"
fold was relying on this, which is why I had to tweak it to not
assume whether inversion is needed based on just the predicate.
Proof: https://alive2.llvm.org/ce/z/_SP_rQ
Differential Revision: https://reviews.llvm.org/D113366
More information about the All-commits
mailing list