mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-19 13:38:56 +00:00
fix indentation of switch statements, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93106 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6091e0289b
commit
abff82d99e
@ -140,79 +140,79 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
Value *V1, *V2;
|
Value *V1, *V2;
|
||||||
ConstantInt *CC;
|
ConstantInt *CC;
|
||||||
switch (Op0BO->getOpcode()) {
|
switch (Op0BO->getOpcode()) {
|
||||||
default: break;
|
default: break;
|
||||||
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() &&
|
||||||
match(Op0BO->getOperand(1), m_Shr(m_Value(V1),
|
match(Op0BO->getOperand(1), m_Shr(m_Value(V1),
|
||||||
m_Specific(Op1)))) {
|
m_Specific(Op1)))) {
|
||||||
Value *YS = // (Y << C)
|
Value *YS = // (Y << C)
|
||||||
Builder->CreateShl(Op0BO->getOperand(0), Op1, Op0BO->getName());
|
Builder->CreateShl(Op0BO->getOperand(0), Op1, Op0BO->getName());
|
||||||
// (X + (Y << C))
|
// (X + (Y << C))
|
||||||
Value *X = Builder->CreateBinOp(Op0BO->getOpcode(), YS, V1,
|
Value *X = Builder->CreateBinOp(Op0BO->getOpcode(), YS, V1,
|
||||||
Op0BO->getOperand(1)->getName());
|
Op0BO->getOperand(1)->getName());
|
||||||
uint32_t Op1Val = Op1->getLimitedValue(TypeBits);
|
uint32_t Op1Val = Op1->getLimitedValue(TypeBits);
|
||||||
return BinaryOperator::CreateAnd(X, ConstantInt::get(I.getContext(),
|
return BinaryOperator::CreateAnd(X, ConstantInt::get(I.getContext(),
|
||||||
APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val)));
|
APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val)));
|
||||||
}
|
|
||||||
|
|
||||||
// Turn (Y + ((X >> C) & CC)) << C -> ((X & (CC << C)) + (Y << C))
|
|
||||||
Value *Op0BOOp1 = Op0BO->getOperand(1);
|
|
||||||
if (isLeftShift && Op0BOOp1->hasOneUse() &&
|
|
||||||
match(Op0BOOp1,
|
|
||||||
m_And(m_Shr(m_Value(V1), m_Specific(Op1)),
|
|
||||||
m_ConstantInt(CC))) &&
|
|
||||||
cast<BinaryOperator>(Op0BOOp1)->getOperand(0)->hasOneUse()) {
|
|
||||||
Value *YS = // (Y << C)
|
|
||||||
Builder->CreateShl(Op0BO->getOperand(0), Op1,
|
|
||||||
Op0BO->getName());
|
|
||||||
// X & (CC << C)
|
|
||||||
Value *XM = Builder->CreateAnd(V1, ConstantExpr::getShl(CC, Op1),
|
|
||||||
V1->getName()+".mask");
|
|
||||||
return BinaryOperator::Create(Op0BO->getOpcode(), YS, XM);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FALL THROUGH.
|
// Turn (Y + ((X >> C) & CC)) << C -> ((X & (CC << C)) + (Y << C))
|
||||||
case Instruction::Sub: {
|
Value *Op0BOOp1 = Op0BO->getOperand(1);
|
||||||
// Turn ((X >> C) + Y) << C -> (X + (Y << C)) & (~0 << C)
|
if (isLeftShift && Op0BOOp1->hasOneUse() &&
|
||||||
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
match(Op0BOOp1,
|
||||||
match(Op0BO->getOperand(0), m_Shr(m_Value(V1),
|
m_And(m_Shr(m_Value(V1), m_Specific(Op1)),
|
||||||
m_Specific(Op1)))) {
|
m_ConstantInt(CC))) &&
|
||||||
Value *YS = // (Y << C)
|
cast<BinaryOperator>(Op0BOOp1)->getOperand(0)->hasOneUse()) {
|
||||||
Builder->CreateShl(Op0BO->getOperand(1), Op1, Op0BO->getName());
|
Value *YS = // (Y << C)
|
||||||
// (X + (Y << C))
|
Builder->CreateShl(Op0BO->getOperand(0), Op1,
|
||||||
Value *X = Builder->CreateBinOp(Op0BO->getOpcode(), V1, YS,
|
Op0BO->getName());
|
||||||
Op0BO->getOperand(0)->getName());
|
// X & (CC << C)
|
||||||
uint32_t Op1Val = Op1->getLimitedValue(TypeBits);
|
Value *XM = Builder->CreateAnd(V1, ConstantExpr::getShl(CC, Op1),
|
||||||
return BinaryOperator::CreateAnd(X, ConstantInt::get(I.getContext(),
|
V1->getName()+".mask");
|
||||||
APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val)));
|
return BinaryOperator::Create(Op0BO->getOpcode(), YS, XM);
|
||||||
}
|
|
||||||
|
|
||||||
// Turn (((X >> C)&CC) + Y) << C -> (X + (Y << C)) & (CC << C)
|
|
||||||
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
|
||||||
match(Op0BO->getOperand(0),
|
|
||||||
m_And(m_Shr(m_Value(V1), m_Value(V2)),
|
|
||||||
m_ConstantInt(CC))) && V2 == Op1 &&
|
|
||||||
cast<BinaryOperator>(Op0BO->getOperand(0))
|
|
||||||
->getOperand(0)->hasOneUse()) {
|
|
||||||
Value *YS = // (Y << C)
|
|
||||||
Builder->CreateShl(Op0BO->getOperand(1), Op1, Op0BO->getName());
|
|
||||||
// X & (CC << C)
|
|
||||||
Value *XM = Builder->CreateAnd(V1, ConstantExpr::getShl(CC, Op1),
|
|
||||||
V1->getName()+".mask");
|
|
||||||
|
|
||||||
return BinaryOperator::Create(Op0BO->getOpcode(), XM, YS);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FALL THROUGH.
|
||||||
|
case Instruction::Sub: {
|
||||||
|
// Turn ((X >> C) + Y) << C -> (X + (Y << C)) & (~0 << C)
|
||||||
|
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
||||||
|
match(Op0BO->getOperand(0), m_Shr(m_Value(V1),
|
||||||
|
m_Specific(Op1)))) {
|
||||||
|
Value *YS = // (Y << C)
|
||||||
|
Builder->CreateShl(Op0BO->getOperand(1), Op1, Op0BO->getName());
|
||||||
|
// (X + (Y << C))
|
||||||
|
Value *X = Builder->CreateBinOp(Op0BO->getOpcode(), V1, YS,
|
||||||
|
Op0BO->getOperand(0)->getName());
|
||||||
|
uint32_t Op1Val = Op1->getLimitedValue(TypeBits);
|
||||||
|
return BinaryOperator::CreateAnd(X, ConstantInt::get(I.getContext(),
|
||||||
|
APInt::getHighBitsSet(TypeBits, TypeBits-Op1Val)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Turn (((X >> C)&CC) + Y) << C -> (X + (Y << C)) & (CC << C)
|
||||||
|
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
|
||||||
|
match(Op0BO->getOperand(0),
|
||||||
|
m_And(m_Shr(m_Value(V1), m_Value(V2)),
|
||||||
|
m_ConstantInt(CC))) && V2 == Op1 &&
|
||||||
|
cast<BinaryOperator>(Op0BO->getOperand(0))
|
||||||
|
->getOperand(0)->hasOneUse()) {
|
||||||
|
Value *YS = // (Y << C)
|
||||||
|
Builder->CreateShl(Op0BO->getOperand(1), Op1, Op0BO->getName());
|
||||||
|
// X & (CC << C)
|
||||||
|
Value *XM = Builder->CreateAnd(V1, ConstantExpr::getShl(CC, Op1),
|
||||||
|
V1->getName()+".mask");
|
||||||
|
|
||||||
|
return BinaryOperator::Create(Op0BO->getOpcode(), XM, YS);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// If the operand is an bitwise operator with a constant RHS, and the
|
// If the operand is an bitwise operator with a constant RHS, and the
|
||||||
// shift is the only use, we can pull it out of the shift.
|
// shift is the only use, we can pull it out of the shift.
|
||||||
@ -221,17 +221,17 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||||||
bool highBitSet = false; // Transform if high bit of constant set?
|
bool highBitSet = false; // Transform if high bit of constant set?
|
||||||
|
|
||||||
switch (Op0BO->getOpcode()) {
|
switch (Op0BO->getOpcode()) {
|
||||||
default: isValid = false; break; // Do not perform transform!
|
default: isValid = false; break; // Do not perform transform!
|
||||||
case Instruction::Add:
|
case Instruction::Add:
|
||||||
isValid = isLeftShift;
|
isValid = isLeftShift;
|
||||||
break;
|
break;
|
||||||
case Instruction::Or:
|
case Instruction::Or:
|
||||||
case Instruction::Xor:
|
case Instruction::Xor:
|
||||||
highBitSet = false;
|
highBitSet = false;
|
||||||
break;
|
break;
|
||||||
case Instruction::And:
|
case Instruction::And:
|
||||||
highBitSet = true;
|
highBitSet = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a signed shift right, and the high bit is modified
|
// If this is a signed shift right, and the high bit is modified
|
||||||
|
Loading…
x
Reference in New Issue
Block a user