diff options
author | Kadir Cetinkaya <kadircet@google.com> | 2020-01-08 11:21:21 +0100 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2020-01-08 11:21:21 +0100 |
commit | b212eb7159b40c98b3c40619b82b996fb903282b (patch) | |
tree | b231478122829839015cc0f922014c5bd346399d /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | |
parent | 903e5c3028d61481c570c09eeb5e7a920c2d7d38 (diff) | |
download | bcm5719-llvm-b212eb7159b40c98b3c40619b82b996fb903282b.tar.gz bcm5719-llvm-b212eb7159b40c98b3c40619b82b996fb903282b.zip |
Revert "[InstCombine] fold zext of masked bit set/clear"
This reverts commit a041c4ec6f7aa659b235cb67e9231a05e0a33b7d.
This looks like a non-trivial change and there has been no code
reviews (at least there were no phabricator revisions attached to the
commit description). It is also causing a regression in one of our
downstream integration tests, we haven't been able to come up with a
minimal reproducer yet.
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index b9be41840ff..3ba56bbe53e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -922,24 +922,10 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *Cmp, ZExtInst &Zext, } } + // icmp ne A, B is equal to xor A, B when A and B only really have one bit. + // It is also profitable to transform icmp eq into not(xor(A, B)) because that + // may lead to additional simplifications. if (Cmp->isEquality() && Zext.getType() == Cmp->getOperand(0)->getType()) { - // Test if a bit is clear/set using a shifted-one mask: - // zext (icmp eq (and X, (1 << ShAmt)), 0) --> and (lshr (not X), ShAmt), 1 - // zext (icmp ne (and X, (1 << ShAmt)), 0) --> and (lshr X, ShAmt), 1 - Value *X, *ShAmt; - if (Cmp->hasOneUse() && match(Cmp->getOperand(1), m_ZeroInt()) && - match(Cmp->getOperand(0), - m_OneUse(m_c_And(m_Shl(m_One(), m_Value(ShAmt)), m_Value(X))))) { - if (Cmp->getPredicate() == ICmpInst::ICMP_EQ) - X = Builder.CreateNot(X); - Value *Lshr = Builder.CreateLShr(X, ShAmt); - Value *And1 = Builder.CreateAnd(Lshr, ConstantInt::get(X->getType(), 1)); - return replaceInstUsesWith(Zext, And1); - } - - // icmp ne A, B is equal to xor A, B when A and B only really have one bit. - // It is also profitable to transform icmp eq into not(xor(A, B)) because - // that may lead to additional simplifications. if (IntegerType *ITy = dyn_cast<IntegerType>(Zext.getType())) { Value *LHS = Cmp->getOperand(0); Value *RHS = Cmp->getOperand(1); |