[llvm] [InstCombine] Extend Fold of Zero-extended Bit Test (PR #102100)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 6 04:04:12 PDT 2024
================
@@ -997,7 +997,8 @@ Instruction *InstCombinerImpl::transformZExtICmp(ICmpInst *Cmp,
X = Builder.CreateNot(X);
Value *Lshr = Builder.CreateLShr(X, ShAmt);
Value *And1 = Builder.CreateAnd(Lshr, ConstantInt::get(X->getType(), 1));
- return replaceInstUsesWith(Zext, And1);
+ return replaceInstUsesWith(
+ Zext, Builder.CreateZExtOrTrunc(And1, Zext.getType()));
----------------
nikic wrote:
I think in the ICMP_EQ case, we may also have to check that the shl is one use now? Otherwise we replace zext+icmp+and with not+lshr+and+zext/trunc, which is more instructions.
https://github.com/llvm/llvm-project/pull/102100
More information about the llvm-commits
mailing list