From 50f2625b22e05d838ddfa17f6861de78cb5e2779 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Tue, 23 Nov 2010 20:42:39 +0000 Subject: [PATCH] Rename SimplifyDistributed to the more meaningfull name SimplifyByFactorizing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120051 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombine.h | 10 +++++----- lib/Transforms/InstCombine/InstCombineAddSub.cpp | 4 ++-- lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 6 +++--- lib/Transforms/InstCombine/InstructionCombining.cpp | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombine.h b/lib/Transforms/InstCombine/InstCombine.h index b492777a472..f89ea508d50 100644 --- a/lib/Transforms/InstCombine/InstCombine.h +++ b/lib/Transforms/InstCombine/InstCombine.h @@ -290,11 +290,11 @@ private: /// operators which are associative or commutative. bool SimplifyAssociativeOrCommutative(BinaryOperator &I); - /// SimplifyDistributed - This tries to simplify binary operations which some - /// other binary operation distributes over (eg "A*B+A*C" -> "A*(B+C)" since - /// addition is distributed over by multiplication). Returns the result of - /// the simplification, or null if no simplification was performed. - Instruction *SimplifyDistributed(BinaryOperator &I); + /// SimplifyByFactorizing - This tries to simplify binary operations which + /// some other binary operation distributes over by factorizing out a common + /// term (eg "(A*B)+(A*C)" -> "A*(B+C)"). Returns the simplified value, or + /// null if no simplification was performed. + Instruction *SimplifyByFactorizing(BinaryOperator &I); /// SimplifyDemandedUseBits - Attempts to replace V with a simpler value /// based on the demanded bits. diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index b2919d8833b..26679a21895 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -91,7 +91,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { I.hasNoUnsignedWrap(), TD)) return ReplaceInstUsesWith(I, V); - if (Instruction *NV = SimplifyDistributed(I)) // (A*B)+(A*C) -> A*(B+C) + if (Instruction *NV = SimplifyByFactorizing(I)) // (A*B)+(A*C) -> A*(B+C) return NV; if (Constant *RHSC = dyn_cast(RHS)) { @@ -550,7 +550,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { if (Op0 == Op1) // sub X, X -> 0 return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); - if (Instruction *NV = SimplifyDistributed(I)) // (A*B)-(A*C) -> A*(B-C) + if (Instruction *NV = SimplifyByFactorizing(I)) // (A*B)-(A*C) -> A*(B-C) return NV; // If this is a 'B = x-(-A)', change to B = x+A. This preserves NSW/NUW. diff --git a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index e9d72a4153e..41734f6ac9d 100644 --- a/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -984,7 +984,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) { if (Value *V = SimplifyAndInst(Op0, Op1, TD)) return ReplaceInstUsesWith(I, V); - if (Instruction *NV = SimplifyDistributed(I)) // (A|B)&(A|C) -> A|(B&C) + if (Instruction *NV = SimplifyByFactorizing(I)) // (A|B)&(A|C) -> A|(B&C) return NV; // See if we can simplify any instructions used by the instruction whose sole @@ -1695,7 +1695,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { if (Value *V = SimplifyOrInst(Op0, Op1, TD)) return ReplaceInstUsesWith(I, V); - if (Instruction *NV = SimplifyDistributed(I)) // (A&B)|(A&C) -> A&(B|C) + if (Instruction *NV = SimplifyByFactorizing(I)) // (A&B)|(A&C) -> A&(B|C) return NV; // See if we can simplify any instructions used by the instruction whose sole @@ -1966,7 +1966,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (Value *V = SimplifyXorInst(Op0, Op1, TD)) return ReplaceInstUsesWith(I, V); - if (Instruction *NV = SimplifyDistributed(I)) // (A&B)^(A&C) -> A&(B^C) + if (Instruction *NV = SimplifyByFactorizing(I)) // (A&B)^(A&C) -> A&(B^C) return NV; // See if we can simplify any instructions used by the instruction whose sole diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 22651e30f38..29e4e032248 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -288,11 +288,11 @@ static bool RightDistributesOverLeft(Instruction::BinaryOps LOp, return false; } -/// SimplifyDistributed - This tries to simplify binary operations which some -/// other binary operation distributes over (eg "A*B+A*C" -> "A*(B+C)" since -/// addition is distributed over by multiplication). Returns the result of -/// the simplification, or null if no simplification was performed. -Instruction *InstCombiner::SimplifyDistributed(BinaryOperator &I) { +/// SimplifyByFactorizing - This tries to simplify binary operations which +/// some other binary operation distributes over by factorizing out a common +/// term (eg "(A*B)+(A*C)" -> "A*(B+C)"). Returns the simplified value, or +/// null if no simplification was performed. +Instruction *InstCombiner::SimplifyByFactorizing(BinaryOperator &I) { BinaryOperator *Op0 = dyn_cast(I.getOperand(0)); BinaryOperator *Op1 = dyn_cast(I.getOperand(1)); if (!Op0 || !Op1 || Op0->getOpcode() != Op1->getOpcode())