summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-10 01:04:31 +0000
committerChris Lattner <sabre@nondot.org>2010-01-10 01:04:31 +0000
commitc95a7a21b7237c52c01b02e80d0ea100d4d933cb (patch)
treef2bed9118a2598270ab058a1bc75bb77fb221e74 /llvm/lib
parent883550afe8902dc428f9f63d8b549388491c388b (diff)
downloadbcm5719-llvm-c95a7a21b7237c52c01b02e80d0ea100d4d933cb.tar.gz
bcm5719-llvm-c95a7a21b7237c52c01b02e80d0ea100d4d933cb.zip
clean up this xform by using m_Trunc.
llvm-svn: 93092
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 4bea64d9a6f..8a2e8447ab7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1035,20 +1035,17 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
// %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;
OpenPOWER on IntegriCloud