diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-06-12 22:47:53 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-06-12 22:47:53 +0000 |
commit | 7e7c9cc31a9c0ca337235ae04fc268e58da1d01b (patch) | |
tree | 003e25cbb32e0c4418f219c2f2ce06ef1aeca66b /lib/Transforms/InstCombine/InstCombineCompares.cpp | |
parent | b73cd94292f1edc464c90333828737499197860d (diff) | |
download | llvm-7e7c9cc31a9c0ca337235ae04fc268e58da1d01b.tar.gz llvm-7e7c9cc31a9c0ca337235ae04fc268e58da1d01b.tar.bz2 llvm-7e7c9cc31a9c0ca337235ae04fc268e58da1d01b.tar.xz |
Simplify code. No functionality changes, name changes aside.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCompares.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index c7ed098cbf..92cbc1b7f1 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1087,19 +1087,14 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, // have its sign bit set or if it is an equality comparison. // Extending a relational comparison when we're checking the sign // bit would not work. - if (Cast->hasOneUse() && - (ICI.isEquality() || - (AndCST->getValue().isNonNegative() && RHSV.isNonNegative()))) { - uint32_t BitWidth = - cast<IntegerType>(Cast->getOperand(0)->getType())->getBitWidth(); - APInt NewCST = AndCST->getValue().zext(BitWidth); - APInt NewCI = RHSV.zext(BitWidth); - Value *NewAnd = + if (ICI.isEquality() || + (AndCST->getValue().isNonNegative() && RHSV.isNonNegative())) { + Value *NewAnd = Builder->CreateAnd(Cast->getOperand(0), - ConstantInt::get(ICI.getContext(), NewCST), - LHSI->getName()); + ConstantExpr::getZExt(AndCST, Cast->getSrcTy())); + NewAnd->takeName(LHSI); return new ICmpInst(ICI.getPredicate(), NewAnd, - ConstantInt::get(ICI.getContext(), NewCI)); + ConstantExpr::getZExt(RHS, Cast->getSrcTy())); } } |