diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-12-06 10:59:25 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-12-06 13:26:45 -0500 |
commit | 7250ef3613cc6b81145b9543bafb86d7f9466cde (patch) | |
tree | ce2710d63937362550754cbf465f5a4ca75a176d /llvm/lib | |
parent | db5739658467e20a52f20e769d3580412e13ff87 (diff) | |
download | bcm5719-llvm-7250ef3613cc6b81145b9543bafb86d7f9466cde.tar.gz bcm5719-llvm-7250ef3613cc6b81145b9543bafb86d7f9466cde.zip |
[InstCombine] improve readability; NFC
CreateIntCast returns the input if its type matches, so need to duplicate that check.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index a3c1b2777e3..1ba017d479e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -863,19 +863,15 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *Cmp, ZExtInst &Zext, (Pred == ICmpInst::ICMP_SGT && Op1C->isAllOnesValue())) { if (!DoTransform) return Cmp; - Value *In = Op0; Value *ShAmt = ConstantInt::get(CmpOpType, CmpOpType->getScalarSizeInBits() - 1); - In = Builder.CreateLShr(In, ShAmt, In->getName() + ".lobit"); - if (CmpOpType != ZType) - In = Builder.CreateIntCast(In, ZType, false /*ZExt*/); + Value *Sh = Builder.CreateLShr(Op0, ShAmt, Op0->getName() + ".lobit"); + Value *Cast = Builder.CreateIntCast(Sh, ZType, false /*ZExt*/); + // Invert low bit if testing for positive. + if (Pred == ICmpInst::ICMP_SGT) + Cast = Builder.CreateXor(Cast, ConstantInt::get(CmpOpType, 1)); - if (Pred == ICmpInst::ICMP_SGT) { - Constant *One = ConstantInt::get(CmpOpType, 1); - In = Builder.CreateXor(In, One, In->getName() + ".not"); - } - - return replaceInstUsesWith(Zext, In); + return replaceInstUsesWith(Zext, Cast); } // zext (X == 0) to i32 --> X^1 iff X has only the low bit set. |