diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2008-07-07 06:15:49 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2008-07-07 06:15:49 +0000 |
| commit | 7fd27895f39442798e1f4324301bb2d20888100f (patch) | |
| tree | db1249b628f217e8147f71532b5a4b069728715e /lib | |
| parent | 31376589fcfc44bd3e17ab514d5569bd771d156f (diff) | |
| download | external_llvm-7fd27895f39442798e1f4324301bb2d20888100f.zip external_llvm-7fd27895f39442798e1f4324301bb2d20888100f.tar.gz external_llvm-7fd27895f39442798e1f4324301bb2d20888100f.tar.bz2 | |
Handle 'lshr' instruction with SCEVUDiv object.
Comment the xor %x, -1 case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53167 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index d615c75..4462986 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1742,12 +1742,14 @@ 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>(U->getOperand(1))) { + // 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 (CI->getValue().isSignBit()) return SE.getAddExpr(getSCEV(U->getOperand(0)), getSCEV(U->getOperand(1))); + + // If the RHS of xor is -1, then this is a not operation. else if (CI->isAllOnesValue()) return SE.getNotSCEV(getSCEV(U->getOperand(0))); } @@ -1763,6 +1765,16 @@ SCEVHandle ScalarEvolutionsImpl::createSCEV(Value *V) { } break; + case Instruction::LShr: + // Turn logical shift right of a constant into a unsigned divide. + if (ConstantInt *SA = dyn_cast<ConstantInt>(U->getOperand(1))) { + uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth(); + Constant *X = ConstantInt::get( + APInt(BitWidth, 1).shl(SA->getLimitedValue(BitWidth))); + return SE.getUDivExpr(getSCEV(U->getOperand(0)), getSCEV(X)); + } + break; + case Instruction::Trunc: return SE.getTruncateExpr(getSCEV(U->getOperand(0)), U->getType()); |
