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
This commit is contained in:
Chris Lattner
2009-11-10 22:39:16 +00:00
parent 40d8c28b27
commit 055d046f48
2 changed files with 53 additions and 2 deletions

View File

@@ -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.