[llvm-commits] [llvm] r93092 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
Chris Lattner
sabre at nondot.org
Sat Jan 9 17:04:31 PST 2010
Author: lattner
Date: Sat Jan 9 19:04:31 2010
New Revision: 93092
URL: http://llvm.org/viewvc/llvm-project?rev=93092&view=rev
Log:
clean up this xform by using m_Trunc.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp?rev=93092&r1=93091&r2=93092&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp Sat Jan 9 19:04:31 2010
@@ -1035,20 +1035,17 @@
// %a = shl i32 %i, 30
// %d = ashr i32 %a, 30
Value *A = 0;
- // FIXME: GENERALIZE WITH SIGN BITS.
+ // TODO: Eventually this could be subsumed by EvaluateInDifferentType.
ConstantInt *BA = 0, *CA = 0;
- if (match(Src, m_AShr(m_Shl(m_Value(A), m_ConstantInt(BA)),
+ if (match(Src, m_AShr(m_Shl(m_Trunc(m_Value(A)), m_ConstantInt(BA)),
m_ConstantInt(CA))) &&
- BA == CA && isa<TruncInst>(A)) {
- Value *I = cast<TruncInst>(A)->getOperand(0);
- if (I->getType() == CI.getType()) {
- unsigned MidSize = Src->getType()->getScalarSizeInBits();
- unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
- unsigned ShAmt = CA->getZExtValue()+SrcDstSize-MidSize;
- Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
- I = Builder->CreateShl(I, ShAmtV, CI.getName());
- return BinaryOperator::CreateAShr(I, ShAmtV);
- }
+ BA == CA && A->getType() == CI.getType()) {
+ unsigned MidSize = Src->getType()->getScalarSizeInBits();
+ unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
+ unsigned ShAmt = CA->getZExtValue()+SrcDstSize-MidSize;
+ Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
+ A = Builder->CreateShl(A, ShAmtV, CI.getName());
+ return BinaryOperator::CreateAShr(A, ShAmtV);
}
return 0;
More information about the llvm-commits
mailing list