mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Remove dead code and fix indentation per Chris' review comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33785 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1b19cd35fe
commit
a07cb7def5
@ -4605,16 +4605,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||||||
if (Shift && !Shift->isShift())
|
if (Shift && !Shift->isShift())
|
||||||
Shift = 0;
|
Shift = 0;
|
||||||
|
|
||||||
// Check to see if there is a noop-cast between the shift and the and.
|
|
||||||
if (!Shift) {
|
|
||||||
if (CastInst *CI = dyn_cast<CastInst>(LHSI->getOperand(0)))
|
|
||||||
if (CI->getOpcode() == Instruction::BitCast) {
|
|
||||||
Shift = dyn_cast<BinaryOperator>(CI->getOperand(0));
|
|
||||||
if (Shift && !Shift->isShift())
|
|
||||||
Shift = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstantInt *ShAmt;
|
ConstantInt *ShAmt;
|
||||||
ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : 0;
|
ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : 0;
|
||||||
const Type *Ty = Shift ? Shift->getType() : 0; // Type of the shift.
|
const Type *Ty = Shift ? Shift->getType() : 0; // Type of the shift.
|
||||||
@ -5487,7 +5477,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
case Instruction::And:
|
case Instruction::And:
|
||||||
case Instruction::Or:
|
case Instruction::Or:
|
||||||
case Instruction::Xor:
|
case Instruction::Xor: {
|
||||||
// These operators commute.
|
// These operators commute.
|
||||||
// Turn (Y + (X >> C)) << C -> (X + (Y << C)) & (~0 << C)
|
// Turn (Y + (X >> C)) << C -> (X + (Y << C)) & (~0 << C)
|
||||||
if (isLeftShift && Op0BO->getOperand(1)->hasOneUse() &&
|
if (isLeftShift && Op0BO->getOperand(1)->hasOneUse() &&
|
||||||
@ -5507,10 +5497,11 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Turn (Y + ((X >> C) & CC)) << C -> ((X & (CC << C)) + (Y << C))
|
// Turn (Y + ((X >> C) & CC)) << C -> ((X & (CC << C)) + (Y << C))
|
||||||
if (isLeftShift && Op0BO->getOperand(1)->hasOneUse() &&
|
Value *Op0BOOp1 = Op0BO->getOperand(1);
|
||||||
match(Op0BO->getOperand(1), m_And(m_Shr(m_Value(V1), m_Value(V2)),
|
if (isLeftShift && Op0BOOp1->hasOneUse() && V2 == Op1 &&
|
||||||
m_ConstantInt(CC))) && V2 == Op1 &&
|
match(Op0BOOp1,
|
||||||
cast<BinaryOperator>(Op0BO->getOperand(1))->getOperand(0)->hasOneUse()) {
|
m_And(m_Shr(m_Value(V1), m_Value(V2)),m_ConstantInt(CC))) &&
|
||||||
|
cast<BinaryOperator>(Op0BOOp1)->getOperand(0)-> hasOneUse()) {
|
||||||
Instruction *YS = BinaryOperator::createShl(
|
Instruction *YS = BinaryOperator::createShl(
|
||||||
Op0BO->getOperand(0), Op1,
|
Op0BO->getOperand(0), Op1,
|
||||||
Op0BO->getName());
|
Op0BO->getName());
|
||||||
@ -5522,9 +5513,10 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
|
|
||||||
return BinaryOperator::create(Op0BO->getOpcode(), YS, XM);
|
return BinaryOperator::create(Op0BO->getOpcode(), YS, XM);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FALL THROUGH.
|
// FALL THROUGH.
|
||||||
case Instruction::Sub:
|
case Instruction::Sub: {
|
||||||
// Turn ((X >> C) + Y) << C -> (X + (Y << C)) & (~0 << C)
|
// Turn ((X >> C) + Y) << C -> (X + (Y << C)) & (~0 << C)
|
||||||
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
||||||
match(Op0BO->getOperand(0),
|
match(Op0BO->getOperand(0),
|
||||||
@ -5562,6 +5554,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5616,12 +5609,6 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
BinaryOperator *ShiftOp = dyn_cast<BinaryOperator>(Op0);
|
BinaryOperator *ShiftOp = dyn_cast<BinaryOperator>(Op0);
|
||||||
if (ShiftOp && !ShiftOp->isShift())
|
if (ShiftOp && !ShiftOp->isShift())
|
||||||
ShiftOp = 0;
|
ShiftOp = 0;
|
||||||
if (!ShiftOp)
|
|
||||||
if (BitCastInst *CI = dyn_cast<BitCastInst>(Op0))
|
|
||||||
// If this is a noop-integer cast of a shift instruction, use the shift.
|
|
||||||
if (BinaryOperator *SI = dyn_cast<BinaryOperator>(CI->getOperand(0)))
|
|
||||||
if (SI->isShift())
|
|
||||||
ShiftOp = SI;
|
|
||||||
|
|
||||||
if (ShiftOp && isa<ConstantInt>(ShiftOp->getOperand(1))) {
|
if (ShiftOp && isa<ConstantInt>(ShiftOp->getOperand(1))) {
|
||||||
// Find the operands and properties of the input shift. Note that the
|
// Find the operands and properties of the input shift. Note that the
|
||||||
@ -6594,14 +6581,8 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI,
|
|||||||
else
|
else
|
||||||
return BinaryOperator::create(BO->getOpcode(), NewSI, MatchOp);
|
return BinaryOperator::create(BO->getOpcode(), NewSI, MatchOp);
|
||||||
}
|
}
|
||||||
|
assert(0 && "Shouldn't get here");
|
||||||
assert(TI->isShift() && "Should only have Shift here");
|
return 0;
|
||||||
if (MatchIsOpZero)
|
|
||||||
return BinaryOperator::create(Instruction::BinaryOps(TI->getOpcode()),
|
|
||||||
MatchOp, NewSI);
|
|
||||||
else
|
|
||||||
return BinaryOperator::create(Instruction::BinaryOps(TI->getOpcode()),
|
|
||||||
NewSI, MatchOp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user