diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-02 05:41:38 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-02 05:41:38 +0000 |
commit | 2811f2a67069be9a1fab05c1fe152098bd8b5028 (patch) | |
tree | d42a0796fde26eadf33682ca14fe95cd403a8981 /lib/Analysis/ScalarEvolution.cpp | |
parent | febabcc02a1303a8e4d9bed76718a32f0273607a (diff) |
Treat xor of signbit like an add.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35586 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 051631e80d..3597b3551c 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1427,7 +1427,16 @@ SCEVHandle ScalarEvolutionsImpl::createSCEV(Value *V) { } } break; - + case Instruction::Xor: + // If the RHS of the xor is a signbit, then this is just an add. + // Instcombine turns add of signbit into xor as a strength reduction step. + if (ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1))) { + if (CI->getValue().isSignBit()) + return SCEVAddExpr::get(getSCEV(I->getOperand(0)), + getSCEV(I->getOperand(1))); + } + break; + case Instruction::Shl: // Turn shift left of a constant amount into a multiply. if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) { |