[llvm] r310186 - [InstCombine] Fold (C - X) ^ signmask -> (C + signmask - X).

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 5 15:48:29 PDT 2017


Sorry for the breakage.

~Craig

On Sat, Aug 5, 2017 at 3:47 PM, Chandler Carruth via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Doh, you landed the fix as I wrote the email, sorry for that and thanks!
>
> On Sat, Aug 5, 2017 at 3:46 PM Chandler Carruth <chandlerc at gmail.com>
> wrote:
>
>> Pretty sure this broke most of the build bots:
>> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/5829
>>
>> On Sat, Aug 5, 2017 at 1:01 PM Craig Topper via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: ctopper
>>> Date: Sat Aug  5 13:00:44 2017
>>> New Revision: 310186
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310186&view=rev
>>> Log:
>>> [InstCombine] Fold (C - X) ^ signmask -> (C + signmask - X).
>>>
>>> Modified:
>>>     llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>>>     llvm/trunk/test/Transforms/InstCombine/xor.ll
>>>
>>> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
>>> Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=
>>> 310186&r1=310185&r2=310186&view=diff
>>> ============================================================
>>> ==================
>>> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
>>> (original)
>>> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Sat
>>> Aug  5 13:00:44 2017
>>> @@ -2422,11 +2422,17 @@ Instruction *InstCombiner::visitXor(Bina
>>>    if (ConstantInt *RHSC = dyn_cast<ConstantInt>(Op1)) {
>>>      if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0)) {
>>>        // ~(c-X) == X-c-1 == X+(-c-1)
>>> -      if (Op0I->getOpcode() == Instruction::Sub && RHSC->isMinusOne())
>>> -        if (Constant *Op0I0C = dyn_cast<Constant>(Op0I->getOperand(0)))
>>> {
>>> -          Constant *NegOp0I0C = ConstantExpr::getNeg(Op0I0C);
>>> -          return BinaryOperator::CreateAdd(Op0I->getOperand(1),
>>> -                                           SubOne(NegOp0I0C));
>>> +      if (Op0I->getOpcode() == Instruction::Sub)
>>> +        if (ConstantInt *Op0I0C = dyn_cast<ConstantInt>(Op0I->getOperand(0)))
>>> {
>>> +          if (RHSC->isMinusOne()) {
>>> +            Constant *NegOp0I0C = ConstantExpr::getNeg(Op0I0C);
>>> +            return BinaryOperator::CreateAdd(Op0I->getOperand(1),
>>> +                                             SubOne(NegOp0I0C));
>>> +          } else if (RHSC->getValue().isSignMask()) {
>>> +            // (C - X) ^ signmask -> (C + signmask - X)
>>> +            Constant *C = Builder.getInt(RHSC->getValue() +
>>> Op0I0C->getValue());
>>> +            return BinaryOperator::CreateSub(C, Op0I->getOperand(1));
>>> +          }
>>>          }
>>>
>>>        if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1)))
>>> {
>>> @@ -2440,7 +2446,6 @@ Instruction *InstCombiner::visitXor(Bina
>>>              // (X + C) ^ signmask -> (X + C + signmask)
>>>              Constant *C = Builder.getInt(RHSC->getValue() +
>>> Op0CI->getValue());
>>>              return BinaryOperator::CreateAdd(Op0I->getOperand(0), C);
>>> -
>>>            }
>>>          } else if (Op0I->getOpcode() == Instruction::Or) {
>>>            // (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0
>>>
>>> Modified: llvm/trunk/test/Transforms/InstCombine/xor.ll
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
>>> Transforms/InstCombine/xor.ll?rev=310186&r1=310185&r2=310186&view=diff
>>> ============================================================
>>> ==================
>>> --- llvm/trunk/test/Transforms/InstCombine/xor.ll (original)
>>> +++ llvm/trunk/test/Transforms/InstCombine/xor.ll Sat Aug  5 13:00:44
>>> 2017
>>> @@ -353,6 +353,15 @@ define i32 @test28(i32 %indvar) {
>>>    ret i32 %t214
>>>  }
>>>
>>> +define i32 @test28_sub(i32 %indvar) {
>>> +; CHECK-LABEL: @test28_sub(
>>> +; CHECK-NEXT:    ret i32 -2147483648 <(214)%20748-3648>
>>> +;
>>> +  %t7 = sub i32 -2147483647 <(214)%20748-3647>, %indvar
>>> +  %t214 = xor i32 %t7, -2147483648 <(214)%20748-3648>
>>> +  ret i32 %t214
>>> +}
>>> +
>>>  define i32 @test29(i1 %C) {
>>>  ; CHECK-LABEL: @test29(
>>>  ; CHECK-NEXT:    [[V:%.*]] = select i1 [[C:%.*]], i32 915, i32 113
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170805/1b7c9413/attachment.html>


More information about the llvm-commits mailing list