[llvm-commits] [llvm] r53167 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Nick Lewycky
nicholas at mxc.ca
Sun Jul 6 23:15:50 PDT 2008
Author: nicholas
Date: Mon Jul 7 01:15:49 2008
New Revision: 53167
URL: http://llvm.org/viewvc/llvm-project?rev=53167&view=rev
Log:
Handle 'lshr' instruction with SCEVUDiv object.
Comment the xor %x, -1 case.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=53167&r1=53166&r2=53167&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 7 01:15:49 2008
@@ -1742,12 +1742,14 @@
}
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 @@
}
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());
More information about the llvm-commits
mailing list