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