[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun May 8 21:58:53 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.342 -> 1.343
---
Log message:
implement and.ll:test33
---
Diffs of the changes: (+18 -2)
InstructionCombining.cpp | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.342 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.343
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.342 Sun May 8 12:34:56 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun May 8 23:58:36 2005
@@ -1832,8 +1832,8 @@
ConstantInt *C1; Value *X;
// (X & C1) | C2 --> (X | C2) & (C1|C2)
if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) && isOnlyUse(Op0)) {
- std::string Op0Name = Op0->getName(); Op0->setName("");
- Instruction *Or = BinaryOperator::createOr(X, RHS, Op0Name);
+ Instruction *Or = BinaryOperator::createOr(X, RHS, Op0->getName());
+ Op0->setName("");
InsertNewInstBefore(Or, I);
return BinaryOperator::createAnd(Or, ConstantExpr::getOr(RHS, C1));
}
@@ -1865,6 +1865,22 @@
if (A == Op0 || B == Op0) // A | (A & ?) --> A
return ReplaceInstUsesWith(I, Op0);
+ // (X^C)|Y -> (X|Y)^C iff Y&C == 0
+ if (Op0->hasOneUse() && match(Op0, m_Xor(m_Value(A), m_ConstantInt(C1))) &&
+ MaskedValueIsZero(Op1, C1)) {
+ Instruction *NOr = BinaryOperator::createOr(A, Op1, Op0->getName());
+ Op0->setName("");
+ return BinaryOperator::createXor(InsertNewInstBefore(NOr, I), C1);
+ }
+
+ // Y|(X^C) -> (X|Y)^C iff Y&C == 0
+ if (Op1->hasOneUse() && match(Op1, m_Xor(m_Value(A), m_ConstantInt(C1))) &&
+ MaskedValueIsZero(Op0, C1)) {
+ Instruction *NOr = BinaryOperator::createOr(A, Op0, Op1->getName());
+ Op0->setName("");
+ return BinaryOperator::createXor(InsertNewInstBefore(NOr, I), C1);
+ }
+
// (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)
More information about the llvm-commits
mailing list