summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-08-17 19:58:24 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-08-17 19:58:24 +0000
commit53b44029d663b57ddac9a042a9c04fad7762442f (patch)
tree90d9f4204f41b4ddeff0d2a1f69ea7e8f87afcae /llvm/lib
parentf37daa50dae04e34c34711fba2357e39f74d19a7 (diff)
downloadbcm5719-llvm-53b44029d663b57ddac9a042a9c04fad7762442f.tar.gz
bcm5719-llvm-53b44029d663b57ddac9a042a9c04fad7762442f.zip
Consider the case where xor by -1 and xor by 128 have been combined already to
produce an xor by 127. llvm-svn: 54906
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 32232a65889..defad26f8a1 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -5503,8 +5503,8 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
return new ICmpInst(I.getPredicate(), Op0I->getOperand(0),
Op1I->getOperand(0));
} else {
- // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u a, b
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) {
+ // icmp u/s (a ^ signbit), (b ^ signbit) --> icmp s/u a, b
if (CI->getValue().isSignBit()) {
ICmpInst::Predicate Pred = I.isSignedPredicate()
? I.getUnsignedPredicate()
@@ -5512,6 +5512,17 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
return new ICmpInst(Pred, Op0I->getOperand(0),
Op1I->getOperand(0));
}
+
+ // icmp u/s (a ^ ~signbit), (b ^ ~signbit) --> icmp s/u b, a
+ if ((~CI->getValue()).isSignBit()) {
+ ICmpInst::Predicate Pred = I.isSignedPredicate()
+ ? I.getUnsignedPredicate()
+ : I.getSignedPredicate();
+ Pred = I.getSwappedPredicate(Pred);
+ return new ICmpInst(Pred, Op0I->getOperand(0),
+ Op1I->getOperand(0));
+
+ }
}
}
break;
@@ -5818,6 +5829,17 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
return new ICmpInst(Pred, LHSI->getOperand(0),
ConstantInt::get(RHSV ^ SignBit));
}
+
+ // (icmp u/s (xor A ~SignBit), C) -> (icmp ~s/u A, (xor C ~SignBit))
+ if (!ICI.isEquality() && (~XorCST->getValue()).isSignBit()) {
+ const APInt &NotSignBit = XorCST->getValue();
+ ICmpInst::Predicate Pred = ICI.isSignedPredicate()
+ ? ICI.getUnsignedPredicate()
+ : ICI.getSignedPredicate();
+ Pred = ICI.getSwappedPredicate(Pred);
+ return new ICmpInst(Pred, LHSI->getOperand(0),
+ ConstantInt::get(RHSV ^ NotSignBit));
+ }
}
break;
case Instruction::And: // (icmp pred (and X, AndCST), RHS)
OpenPOWER on IntegriCloud