[all-commits] [llvm/llvm-project] 8fce94: [InstCombine] canonicalize icmp with trunc op into...
RotateRight via All-commits
all-commits at lists.llvm.org
Tue Nov 16 06:29:07 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8fce94f91610bc4614b1fe0bff8f143ea2b54742
https://github.com/llvm/llvm-project/commit/8fce94f91610bc4614b1fe0bff8f143ea2b54742
Author: Sanjay Patel <spatel at rotateright.com>
Date: 2021-11-16 (Tue, 16 Nov 2021)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
M llvm/test/Transforms/InstCombine/icmp-trunc.ll
Log Message:
-----------
[InstCombine] canonicalize icmp with trunc op into mask and cmp, part 2
If C is a high-bit mask:
(trunc X) u< C --> (X & C) != C (are any masked-high-bits clear?)
If C is low-bit mask:
(trunc X) u> C --> (X & ~C) != 0 (are any masked-high-bits set?)
If C is not-of-power-of-2 (one clear bit):
(trunc X) u> C --> (X & (C+1)) == C+1 (are all masked-high-bits set?)
This extends the fold added with:
acabad9ff6bf (https://alive2.llvm.org/ce/z/aFr7qV)
Using decomposeBitTestICmp() to generalize this is a planned follow-up, but that requires removing an inverse fold.
Here are Alive2 generalizations for these folds:
https://alive2.llvm.org/ce/z/u-ZpC_ (ult, the previous patch)
https://alive2.llvm.org/ce/z/YsuAu2 (ult, this patch)
https://alive2.llvm.org/ce/z/ekktQP (ugt, low bitmask)
https://alive2.llvm.org/ce/z/pJY9wR (ugt, one clear bit)
Differential Revision: https://reviews.llvm.org/D112634
More information about the All-commits
mailing list