[llvm] r299658 - [InstCombine] Fix a case where we weren't checking that an instruction had a single use resulting in extra instructions being created.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 6 11:06:05 PDT 2017
I'll work on one. My real objective was to remove this code outright
because it should have been dead because its equivalent to transformations
done by SimplifyDemandedInstructionBits. I did remove it in r299337, but
that broke the tsan buildbot so I had to revert it while I figured out what
was going on. What I discovered was that this code was duplicating
instructions and thus firing when SimplifyDemandedInstructionBits wasn't.
So I fixed the duplication and the tsan bot failure. I figured removing the
duplication first was an easier way to explain the tsan change. Now I plan
to go back to removing it completely.
~Craig
On Thu, Apr 6, 2017 at 10:53 AM, Friedman, Eli <efriedma at codeaurora.org>
wrote:
> 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/Transform
>> s/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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170406/b98446b7/attachment.html>
More information about the llvm-commits
mailing list