[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat May 7 16:49:25 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.340 -> 1.341
---
Log message:
Fix a miscompilation of crafty by clobbering the "A" variable.
---
Diffs of the changes: (+10 -9)
InstructionCombining.cpp | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.340 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.341
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.340 Fri May 6 01:48:21 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat May 7 18:49:08 2005
@@ -1856,8 +1856,16 @@
return NV;
}
- // (A & C1)|(A & C2) == A & (C1|C2)
Value *A, *B; ConstantInt *C1, *C2;
+
+ if (match(Op0, m_And(m_Value(A), m_Value(B))))
+ if (A == Op1 || B == Op1) // (A & ?) | A --> A
+ return ReplaceInstUsesWith(I, Op1);
+ if (match(Op1, m_And(m_Value(A), m_Value(B))))
+ if (A == Op0 || B == Op0) // A | (A & ?) --> A
+ return ReplaceInstUsesWith(I, Op0);
+
+ // (A & C1)|(A & C2) == A & (C1|C2)
if (match(Op0, m_And(m_Value(A), m_ConstantInt(C1))) &&
match(Op1, m_And(m_Value(B), m_ConstantInt(C2))) && A == B)
return BinaryOperator::createAnd(A, ConstantExpr::getOr(C1, C2));
@@ -1869,14 +1877,7 @@
} else {
A = 0;
}
-
- if (match(Op0, m_And(m_Value(A), m_Value(B))))
- if (A == Op1 || B == Op1) // (A & ?) | A --> A
- return ReplaceInstUsesWith(I, Op1);
- if (match(Op1, m_And(m_Value(A), m_Value(B))))
- if (A == Op0 || B == Op0) // A | (A & ?) --> A
- return ReplaceInstUsesWith(I, Op0);
-
+ // Note, A is still live here!
if (match(Op1, m_Not(m_Value(B)))) { // Op0 | ~B
if (Op0 == B)
return ReplaceInstUsesWith(I,
More information about the llvm-commits
mailing list