diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-01-10 01:04:31 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-01-10 01:04:31 +0000 |
| commit | 7a377abeec1e6e4c48121b45637742f9b58f8fe6 (patch) | |
| tree | 3e48cd24214d25d94f8291533620a22654653afe /lib/Transforms | |
| parent | 2b10be2386eef8992abb21110c38ce27e8843ac6 (diff) | |
| download | external_llvm-7a377abeec1e6e4c48121b45637742f9b58f8fe6.zip external_llvm-7a377abeec1e6e4c48121b45637742f9b58f8fe6.tar.gz external_llvm-7a377abeec1e6e4c48121b45637742f9b58f8fe6.tar.bz2 | |
clean up this xform by using m_Trunc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
| -rw-r--r-- | lib/Transforms/InstCombine/InstCombineCasts.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp index 4bea64d..8a2e844 100644 --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/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; |
