[llvm] r299658 - [InstCombine] Fix a case where we weren't checking that an instruction had a single use resulting in extra instructions being created.
Friedman, Eli via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 6 10:53:16 PDT 2017
On 4/6/2017 9:42 AM, Craig Topper via llvm-commits wrote:
> Author: ctopper
> Date: Thu Apr 6 11:42:46 2017
> New Revision: 299658
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299658&view=rev
> Log:
> [InstCombine] Fix a case where we weren't checking that an instruction had a single use resulting in extra instructions being created.
Testcase?
-Eli
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=299658&r1=299657&r2=299658&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Apr 6 11:42:46 2017
> @@ -1332,18 +1332,21 @@ Instruction *InstCombiner::visitAnd(Bina
> // ((A & N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == AndRHS.
> // ((A | N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == 0
> // ((A ^ N) + B) & AndRHS -> (A + B) & AndRHS iff N&AndRHS == 0
> - if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, false, I))
> - return BinaryOperator::CreateAnd(V, AndRHS);
> - if (Value *V = FoldLogicalPlusAnd(Op0RHS, Op0LHS, AndRHS, false, I))
> - return BinaryOperator::CreateAnd(V, AndRHS); // Add commutes
> + if (Op0I->hasOneUse()) {
> + if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, false, I))
> + return BinaryOperator::CreateAnd(V, AndRHS);
> + if (Value *V = FoldLogicalPlusAnd(Op0RHS, Op0LHS, AndRHS, false, I))
> + return BinaryOperator::CreateAnd(V, AndRHS); // Add commutes
> + }
> break;
>
> case Instruction::Sub:
> // ((A & N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == AndRHS.
> // ((A | N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == 0
> // ((A ^ N) - B) & AndRHS -> (A - B) & AndRHS iff N&AndRHS == 0
> - if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, true, I))
> - return BinaryOperator::CreateAnd(V, AndRHS);
> + if (Op0I->hasOneUse())
> + if (Value *V = FoldLogicalPlusAnd(Op0LHS, Op0RHS, AndRHS, true, I))
> + return BinaryOperator::CreateAnd(V, AndRHS);
>
> // -x & 1 -> x & 1
> if (AndRHSMask == 1 && match(Op0LHS, m_Zero()))
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-commits
mailing list