summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-10 22:39:16 +0000
committerChris Lattner <sabre@nondot.org>2009-11-10 22:39:16 +0000
commit9518fbb54ecd4f52f2c3310e868b1b9a8077cea5 (patch)
treeecb92f00431ea583687f00c454590d2b2b8b2c25 /llvm/lib/Transforms/Scalar/JumpThreading.cpp
parent3ad26454307dc99262a762230a2c0d374193acb8 (diff)
downloadbcm5719-llvm-9518fbb54ecd4f52f2c3310e868b1b9a8077cea5.tar.gz
bcm5719-llvm-9518fbb54ecd4f52f2c3310e868b1b9a8077cea5.zip
implement a TODO by teaching jump threading about "xor x, 1".
llvm-svn: 86739
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 36cc1fab40d..cbd8702a422 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -299,8 +299,20 @@ ComputeValueKnownInPredecessors(Value *V, BasicBlock *BB,PredValueInfo &Result){
return !Result.empty();
}
- // TODO: Should handle the NOT form of XOR.
-
+ // Handle the NOT form of XOR.
+ if (I->getOpcode() == Instruction::Xor &&
+ isa<ConstantInt>(I->getOperand(1)) &&
+ cast<ConstantInt>(I->getOperand(1))->isOne()) {
+ ComputeValueKnownInPredecessors(I->getOperand(0), BB, Result);
+ if (Result.empty())
+ return false;
+
+ // Invert the known values.
+ for (unsigned i = 0, e = Result.size(); i != e; ++i)
+ Result[i].first =
+ cast<ConstantInt>(ConstantExpr::getNot(Result[i].first));
+ return true;
+ }
}
// Handle compare with phi operand, where the PHI is defined in this block.
OpenPOWER on IntegriCloud