summaryrefslogtreecommitdiff
path: root/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
commit055d046f483af3c66f4d19a32a17fc63ed2c22d5 (patch)
tree9b163d1aaeb35eb400ee6440ed147558a9f06ce9 /lib/Transforms/Scalar/JumpThreading.cpp
parent40d8c28b27377199b7465ba2c5a2c59c6fd12fa9 (diff)
downloadllvm-055d046f483af3c66f4d19a32a17fc63ed2c22d5.tar.gz
llvm-055d046f483af3c66f4d19a32a17fc63ed2c22d5.tar.bz2
llvm-055d046f483af3c66f4d19a32a17fc63ed2c22d5.tar.xz
implement a TODO by teaching jump threading about "xor x, 1".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86739 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 36cc1fab40..cbd8702a42 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/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.