mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-31 09:25:42 +00:00
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
This commit is contained in:
@@ -1035,20 +1035,17 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
|
|||||||
// %a = shl i32 %i, 30
|
// %a = shl i32 %i, 30
|
||||||
// %d = ashr i32 %a, 30
|
// %d = ashr i32 %a, 30
|
||||||
Value *A = 0;
|
Value *A = 0;
|
||||||
// FIXME: GENERALIZE WITH SIGN BITS.
|
// TODO: Eventually this could be subsumed by EvaluateInDifferentType.
|
||||||
ConstantInt *BA = 0, *CA = 0;
|
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))) &&
|
m_ConstantInt(CA))) &&
|
||||||
BA == CA && isa<TruncInst>(A)) {
|
BA == CA && A->getType() == CI.getType()) {
|
||||||
Value *I = cast<TruncInst>(A)->getOperand(0);
|
unsigned MidSize = Src->getType()->getScalarSizeInBits();
|
||||||
if (I->getType() == CI.getType()) {
|
unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
|
||||||
unsigned MidSize = Src->getType()->getScalarSizeInBits();
|
unsigned ShAmt = CA->getZExtValue()+SrcDstSize-MidSize;
|
||||||
unsigned SrcDstSize = CI.getType()->getScalarSizeInBits();
|
Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
|
||||||
unsigned ShAmt = CA->getZExtValue()+SrcDstSize-MidSize;
|
A = Builder->CreateShl(A, ShAmtV, CI.getName());
|
||||||
Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt);
|
return BinaryOperator::CreateAShr(A, ShAmtV);
|
||||||
I = Builder->CreateShl(I, ShAmtV, CI.getName());
|
|
||||||
return BinaryOperator::CreateAShr(I, ShAmtV);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user