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 | f5c547d499df86b1ec8166d7b0496ef36a897b4b (patch) | |
tree | afc75af18f94cf79193426da272883938a571a41 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | ecf34435f47307a565b6477ec4a8d11b16154012 (diff) | |
download | bcm5719-llvm-f5c547d499df86b1ec8166d7b0496ef36a897b4b.tar.gz bcm5719-llvm-f5c547d499df86b1ec8166d7b0496ef36a897b4b.zip |
Handle 'lshr' instruction with SCEVUDiv object.
Comment the xor %x, -1 case.
llvm-svn: 53167
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index d615c752b04..4462986f15b 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/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()); |