clean up some comments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92377 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-01-01 00:04:26 +00:00
parent f55e7f54b1
commit 9046193e55

View File

@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This pass reassociates commutative expressions in an order that is designed // This pass reassociates commutative expressions in an order that is designed
// to promote better constant propagation, GCSE, LICM, PRE... // to promote better constant propagation, GCSE, LICM, PRE, etc.
// //
// For example: 4 + (x + 5) -> x + (4 + 5) // For example: 4 + (x + 5) -> x + (4 + 5)
// //
@ -386,7 +386,7 @@ static Value *NegateValue(Value *V, Instruction *BI) {
// X = -(A+12+C+D) into X = -A + -12 + -C + -D = -12 + -A + -C + -D // X = -(A+12+C+D) into X = -A + -12 + -C + -D = -12 + -A + -C + -D
// so that later, a: Y = 12+X could get reassociated with the -12 to eliminate // so that later, a: Y = 12+X could get reassociated with the -12 to eliminate
// the constants. We assume that instcombine will clean up the mess later if // the constants. We assume that instcombine will clean up the mess later if
// we introduce tons of unnecessary negation instructions... // we introduce tons of unnecessary negation instructions.
// //
if (Instruction *I = dyn_cast<Instruction>(V)) if (Instruction *I = dyn_cast<Instruction>(V))
if (I->getOpcode() == Instruction::Add && I->hasOneUse()) { if (I->getOpcode() == Instruction::Add && I->hasOneUse()) {
@ -464,11 +464,11 @@ static bool ShouldBreakUpSubtract(Instruction *Sub) {
/// reassociation. /// reassociation.
static Instruction *BreakUpSubtract(Instruction *Sub, static Instruction *BreakUpSubtract(Instruction *Sub,
DenseMap<AssertingVH<>, unsigned> &ValueRankMap) { DenseMap<AssertingVH<>, unsigned> &ValueRankMap) {
// Convert a subtract into an add and a neg instruction... so that sub // Convert a subtract into an add and a neg instruction. This allows sub
// instructions can be commuted with other add instructions... // instructions to be commuted with other add instructions.
// //
// Calculate the negative value of Operand 1 of the sub instruction... // Calculate the negative value of Operand 1 of the sub instruction,
// and set it as the RHS of the add instruction we just made... // and set it as the RHS of the add instruction we just made.
// //
Value *NegVal = NegateValue(Sub->getOperand(1), Sub); Value *NegVal = NegateValue(Sub->getOperand(1), Sub);
Instruction *New = Instruction *New =
@ -628,7 +628,7 @@ static Value *OptimizeAndOrXor(unsigned Opcode,
if (e == 2) if (e == 2)
return Constant::getNullValue(Ops[0].Op->getType()); return Constant::getNullValue(Ops[0].Op->getType());
// ... X^X -> ... // Y ^ X^X -> Y
Ops.erase(Ops.begin()+i, Ops.begin()+i+2); Ops.erase(Ops.begin()+i, Ops.begin()+i+2);
i -= 1; e -= 2; i -= 1; e -= 2;
++NumAnnihil; ++NumAnnihil;
@ -821,27 +821,27 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
switch (Opcode) { switch (Opcode) {
default: break; default: break;
case Instruction::And: case Instruction::And:
if (CstVal->isZero()) // ... & 0 -> 0 if (CstVal->isZero()) // X & 0 -> 0
return CstVal; return CstVal;
if (CstVal->isAllOnesValue()) // ... & -1 -> ... if (CstVal->isAllOnesValue()) // X & -1 -> X
Ops.pop_back(); Ops.pop_back();
break; break;
case Instruction::Mul: case Instruction::Mul:
if (CstVal->isZero()) { // ... * 0 -> 0 if (CstVal->isZero()) { // X * 0 -> 0
++NumAnnihil; ++NumAnnihil;
return CstVal; return CstVal;
} }
if (cast<ConstantInt>(CstVal)->isOne()) if (cast<ConstantInt>(CstVal)->isOne())
Ops.pop_back(); // ... * 1 -> ... Ops.pop_back(); // X * 1 -> X
break; break;
case Instruction::Or: case Instruction::Or:
if (CstVal->isAllOnesValue()) // ... | -1 -> -1 if (CstVal->isAllOnesValue()) // X | -1 -> -1
return CstVal; return CstVal;
// FALLTHROUGH! // FALLTHROUGH!
case Instruction::Add: case Instruction::Add:
case Instruction::Xor: case Instruction::Xor:
if (CstVal->isZero()) // ... [|^+] 0 -> ... if (CstVal->isZero()) // X [|^+] 0 -> X
Ops.pop_back(); Ops.pop_back();
break; break;
} }