aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-05 07:01:16 +0000
committerChris Lattner <sabre@nondot.org>2010-01-05 07:01:16 +0000
commitdea34da6f8e88d52746c00e55dc0b32b93f8a2b1 (patch)
tree2dc300eb0c6c1883e348cb29828a22b1a47b8085
parenta317e044fb6ababf4dc6dd85001ce402a959f9fc (diff)
downloadexternal_llvm-dea34da6f8e88d52746c00e55dc0b32b93f8a2b1.zip
external_llvm-dea34da6f8e88d52746c00e55dc0b32b93f8a2b1.tar.gz
external_llvm-dea34da6f8e88d52746c00e55dc0b32b93f8a2b1.tar.bz2
eliminate AssociativeOpt and its last uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92697 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp37
1 files changed, 2 insertions, 35 deletions
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
index f9acd20..ca311dd 100644
--- a/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -288,23 +288,6 @@ static Constant *SubOne(ConstantInt *C) {
}
-/// AssociativeOpt - Perform an optimization on an associative operator. This
-/// function is designed to check a chain of associative operators for a
-/// potential to apply a certain optimization. Since the optimization may be
-/// applicable if the expression was reassociated, this checks the chain, then
-/// reassociates the expression as necessary to expose the optimization
-/// opportunity. This makes use of a special Functor, which must define
-/// 'shouldApply' and 'apply' methods.
-///
-template<typename Functor>
-static Instruction *AssociativeOpt(BinaryOperator &Root, const Functor &F) {
- // Quick check, see if the immediate LHS matches...
- if (F.shouldApply(Root.getOperand(0)))
- return F.apply(Root);
-
- return 0;
-}
-
static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
InstCombiner *IC) {
if (CastInst *CI = dyn_cast<CastInst>(&I))
@@ -2801,20 +2784,6 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
return Changed ? &I : 0;
}
-namespace {
-
-// XorSelf - Implements: X ^ X --> 0
-struct XorSelf {
- Value *RHS;
- XorSelf(Value *rhs) : RHS(rhs) {}
- bool shouldApply(Value *LHS) const { return LHS == RHS; }
- Instruction *apply(BinaryOperator &Xor) const {
- return &Xor;
- }
-};
-
-}
-
Instruction *InstCombiner::visitXor(BinaryOperator &I) {
bool Changed = SimplifyCommutative(I);
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
@@ -2827,11 +2796,9 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
return ReplaceInstUsesWith(I, Op1); // X ^ undef -> undef
}
- // xor X, X = 0, even if X is nested in a sequence of Xor's.
- if (Instruction *Result = AssociativeOpt(I, XorSelf(Op1))) {
- assert(Result == &I && "AssociativeOpt didn't work?"); Result=Result;
+ // xor X, X = 0
+ if (Op0 == Op1)
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
- }
// See if we can simplify any instructions used by the instruction whose sole
// purpose is to compute bits we don't care about.