<div dir="ltr"><div>This should fix it:</div><div><a href="https://reviews.llvm.org/rL336965">https://reviews.llvm.org/rL336965</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 12, 2018 at 7:03 PM, Michael Zolotukhin <span dir="ltr"><<a href="mailto:mzolotukhin@apple.com" target="_blank">mzolotukhin@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Great, thank you!<div><br></div><div>Michael<div><div class="h5"><br><div><br><blockquote type="cite"><div>On Jul 12, 2018, at 5:56 PM, Sanjay Patel <<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a>> wrote:</div><br class="m_-7673968240794662350Apple-interchange-newline"><div><div dir="ltr">I'll post a fix soon. Running tests locally to make sure I didn't break anything else!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 12, 2018 at 6:31 PM, Michael Zolotukhin <span dir="ltr"><<a href="mailto:mzolotukhin@apple.com" target="_blank">mzolotukhin@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><br><div><span><br><blockquote type="cite"><div>On Jul 12, 2018, at 5:19 PM, Sanjay Patel <<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a>> wrote:</div><br class="m_-7673968240794662350m_1860343899412736250Apple-interchange-newline"><div><div dir="ltr"><div>Thanks for letting me know. Not sure how it would've changed, but I'll take a look.</div><div><br></div><div> I see that bugpoint doesn't reduce this further. Any chance that you did that manually?</div></div></div></blockquote></span>Yeah, I’ve already run it through bugpoint. I didn’t try to reduce it further, but in the debugger I saw the following scenario:</div><div><div><font size="1" face="Menlo">(lldb) p CxtI.dump()</font></div><div><font size="1" face="Menlo">  %C3 = and i1 %C7, %C5</font></div><div><font size="1" face="Menlo">(lldb) p LHS->dump()</font></div><div><font size="1" face="Menlo">  %C7 = icmp slt i16 %L7, 0</font></div><div><font size="1" face="Menlo">(lldb) p RHS->dump()</font></div><div><font size="1" face="Menlo">  %C5 = icmp slt i16 %L7, 1</font></div><div><br></div><div>And then we abort in the switch on PredL where we don’t have a handler for PredL=SLT. Maybe it’s been relying on some canonicalization which no longer happens?</div><div><br></div><div>Thanks,</div><div>Michael</div><div><div class="m_-7673968240794662350h5"><div><br></div><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>My first guess is that we are missing something in InstSimplify because InstCombine is assuming the easy combination of cmps are already gone.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 12, 2018 at 3:52 PM, Mikhail Zolotukhin <span dir="ltr"><<a href="mailto:mzolotukhin@apple.com" target="_blank">mzolotukhin@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Hi Sanjay,<div><br></div><div>Our fuzzer-bot detected a failure after this change. Here is a reproducer:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font size="1" face="Menlo">$ cat fuzz.ll</font></div><div><font size="1" face="Menlo">source_filename = "M"</font></div><div><font size="1" face="Menlo">target triple = "x86_64-apple-darwin17.6.0"</font></div><div><font size="1" face="Menlo"><br></font></div><div><font size="1" face="Menlo">define void @f() {</font></div><div><font size="1" face="Menlo">BB:</font></div><div><font size="1" face="Menlo">  %A8 = alloca i16</font></div><div><font size="1" face="Menlo">  %L7 = load i16, i16* %A8</font></div><div><font size="1" face="Menlo">  %G21 = getelementptr i16, i16* %A8, i8 -1</font></div><div><font size="1" face="Menlo">  %B11 = udiv i16 %L7, -1</font></div><div><font size="1" face="Menlo">  %G4 = getelementptr i16, i16* %A8, i16 %B11</font></div><div><font size="1" face="Menlo">  %L2 = load i16, i16* %G4</font></div><div><font size="1" face="Menlo">  %L = load i16, i16* %G4</font></div><div><font size="1" face="Menlo">  %B23 = mul i16 %B11, %B11</font></div><div><font size="1" face="Menlo">  %L4 = load i16, i16* %A8</font></div><div><font size="1" face="Menlo">  %B21 = sdiv i16 %L7, %L4</font></div><div><font size="1" face="Menlo">  %B7 = sub i16 0, %B21</font></div><div><font size="1" face="Menlo">  %B18 = mul i16 %B23, %B7</font></div><div><font size="1" face="Menlo">  %C10 = icmp ugt i16 %L, %B11</font></div><div><font size="1" face="Menlo">  %B20 = and i16 %L7, %L2</font></div><div><font size="1" face="Menlo">  %B1 = mul i1 %C10, true</font></div><div><font size="1" face="Menlo">  %C5 = icmp sle i16 %B21, %L</font></div><div><font size="1" face="Menlo">  %C11 = icmp ule i16 %B21, %L</font></div><div><font size="1" face="Menlo">  %C7 = icmp slt i16 %B20, 0</font></div><div><font size="1" face="Menlo">  %B29 = srem i16 %L4, %B18</font></div><div><font size="1" face="Menlo">  %B15 = add i1 %C7, %C10</font></div><div><font size="1" face="Menlo">  %B19 = add i1 %C11, %B15</font></div><div><font size="1" face="Menlo">  %C6 = icmp sge i1 %C11, %B19</font></div><div><font size="1" face="Menlo">  %B33 = or i16 %B29, %L4</font></div><div><font size="1" face="Menlo">  %C13 = icmp uge i1 %C5, %B1</font></div><div><font size="1" face="Menlo">  %C3 = icmp ult i1 %C13, %C6</font></div><div><font size="1" face="Menlo">  store i16 undef, i16* %G21</font></div><div><font size="1" face="Menlo">  %C18 = icmp ule i1 %C10, %C7</font></div><div><font size="1" face="Menlo">  %G26 = getelementptr i1, i1* null, i1 %C3</font></div><div><font size="1" face="Menlo">  store i16 %B33, i16* undef</font></div><div><font size="1" face="Menlo">  store i1 %C18, i1* undef</font></div><div><font size="1" face="Menlo">  store i1* %G26, i1** undef</font></div><div><font size="1" face="Menlo">  ret void</font></div><div><font size="1" face="Menlo">}</font></div><div><font size="1" face="Menlo"><br></font></div><div><font size="1" face="Menlo">$ bin/opt -instcombine fuzz.ll -disable-output</font></div><div><font size="1" face="Menlo">Unknown integer condition code!</font></div><div><font size="1" face="Menlo">UNREACHABLE executed at /Users/mvzolotu/devel/mono/llv<wbr>m-project/llvm/lib/Transforms/<wbr>InstCombine/InstCombineAndOrXo<wbr>r.cpp:1034!</font></div></blockquote><div><br></div><div>I took a look at the code of foldAndOfICmps, and indeed we don’t have a code to handle %I1=%X < 0, %I2=%X < 1, %I3 = %I1 && %I2.</div><div>What would be the best way to handle it (and why didn’t we hit it before)?</div><div><br></div><div>Thanks,</div><div>Michael</div><div><div class="m_-7673968240794662350m_1860343899412736250h5"><div><div><br><blockquote type="cite"><div>On Jun 21, 2018, at 10:06 AM, Sanjay Patel via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="m_-7673968240794662350m_1860343899412736250m_5844902724887122003Apple-interchange-newline"><div><div>Author: spatel<br>Date: Thu Jun 21 10:06:36 2018<br>New Revision: 335258<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=335258&view=rev" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=335258&view=rev</a><br>Log:<br>[InstCombine] simplify binops before trying other folds<br><br>This is outwardly NFC from what I can tell, but it should be more efficient <br>to simplify first (despite the name, SimplifyAssociativeOrCommutati<wbr>ve does<br>not actually simplify as InstSimplify does - it creates/morphs instructions).<br><br>This should make it easier to refactor duplicated code that runs for all binops.<br><br>Modified:<br>    llvm/trunk/lib/Transforms/I<wbr>nstCombine/InstCombineAddSub.c<wbr>pp<br>    llvm/trunk/lib/Transforms/I<wbr>nstCombine/InstCombineAndOrXor<wbr>.cpp<br>    llvm/trunk/lib/Transforms/I<wbr>nstCombine/InstCombineMulDivRe<wbr>m.cpp<br>    llvm/trunk/lib/Transforms/I<wbr>nstCombine/InstCombineShifts.c<wbr>pp<br><br>Modified: llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineAddSub.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=335258&r1=335257&r2=335258&view=diff" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/InstCombine/InstCombineAddSu<wbr>b.cpp?rev=335258&r1=335257&r2=<wbr>335258&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineAddSub.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineAddSub.cpp Thu Jun 21 10:06:36 2018<br>@@ -1121,13 +1121,12 @@ static Instruction *canonicalizeLowbitMa<br> }<br><br> Instruction *InstCombiner::visitAdd(Binary<wbr>Operator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);<br>-  if (Value *V =<br>-          SimplifyAddInst(LHS, RHS, I.hasNoSignedWrap(), I.hasNoUnsignedWrap(),<br>-                          SQ.ge<wbr>tWithInstruction(&I)))<br>+  if (Value *V = SimplifyAddInst(I.getOperand(0<wbr>), I.getOperand(1),<br>+                               <wbr>  I.hasNoSignedWrap(), I.hasNoUnsignedWrap(),<br>+                               <wbr>  SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>@@ -1140,6 +1139,7 @@ Instruction *InstCombiner::visitAdd(Bina<br><br>   // FIXME: This should be moved into the above helper function to allow these<br>   // transforms for general constant or constant splat vectors.<br>+  Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);<br>   Type *Ty = I.getType();<br>   if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {<br>     Value *XorLHS = nullptr; ConstantInt *XorRHS = nullptr;<br>@@ -1378,18 +1378,19 @@ Instruction *InstCombiner::visitAdd(Bina<br> }<br><br> Instruction *InstCombiner::visitFAdd(Binar<wbr>yOperator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);<br>-  if (Value *V = SimplifyFAddInst(LHS, RHS, I.getFastMathFlags(),<br>+  if (Value *V = SimplifyFAddInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   I.getFastMathFlags(),<br>                               <wbr>    SQ.getWithInstruction(&I))<wbr>)<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>   if (Instruction *FoldedFAdd = foldBinOpIntoSelectOrPhi(I))<br>     return FoldedFAdd;<br><br>+  Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);<br>   Value *X;<br>   // (-X) + Y --> Y - X<br>   if (match(LHS, m_FNeg(m_Value(X))))<br>@@ -1555,10 +1556,9 @@ Value *InstCombiner::OptimizePointer<wbr>Diff<br> }<br><br> Instruction *InstCombiner::visitSub(Binary<wbr>Operator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V =<br>-          SimplifySubInst(Op0, Op1, I.hasNoSignedWrap(), I.hasNoUnsignedWrap(),<br>-                          SQ.ge<wbr>tWithInstruction(&I)))<br>+  if (Value *V = SimplifySubInst(I.getOperand(0<wbr>), I.getOperand(1),<br>+                               <wbr>  I.hasNoSignedWrap(), I.hasNoUnsignedWrap(),<br>+                               <wbr>  SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -1569,6 +1569,7 @@ Instruction *InstCombiner::visitSub(Bina<br>     return replaceInstUsesWith(I, V);<br><br>   // If this is a 'B = x-(-A)', change to B = x+A.<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (Value *V = dyn_castNegVal(Op1)) {<br>     BinaryOperator *Res = BinaryOperator::CreateAdd(Op0, V);<br><br>@@ -1808,8 +1809,8 @@ Instruction *InstCombiner::visitSub(Bina<br> }<br><br> Instruction *InstCombiner::visitFSub(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyFSubInst(Op0, Op1, I.getFastMathFlags(),<br>+  if (Value *V = SimplifyFSubInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   I.getFastMathFlags(),<br>                               <wbr>    SQ.getWithInstruction(&I))<wbr>)<br>     return replaceInstUsesWith(I, V);<br><br>@@ -1818,6 +1819,7 @@ Instruction *InstCombiner::visitFSub(Bin<br><br>   // Subtraction from -0.0 is the canonical form of fneg.<br>   // fsub nsz 0, X ==> fsub nsz -0.0, X<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (I.hasNoSignedZeros() && match(Op0, m_PosZeroFP()))<br>     return BinaryOperator::CreateFNegFMF(<wbr>Op1, &I);<br><br><br>Modified: llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineAndOrXor.cp<wbr>p<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=335258&r1=335257&r2=335258&view=diff" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/InstCombine/InstCombineAndOr<wbr>Xor.cpp?rev=335258&r1=335257&r<wbr>2=335258&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineAndOrXor.cp<wbr>p (original)<br>+++ llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineAndOrXor.cp<wbr>p Thu Jun 21 10:06:36 2018<br>@@ -1401,11 +1401,11 @@ Instruction *InstCombiner::narrowMaskedB<br> // here. We should standardize that construct where it is needed or choose some<br> // other way to ensure that commutated variants of patterns are not missed.<br> Instruction *InstCombiner::visitAnd(Binary<wbr>Operator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyAndInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyAndInst(I.getOperand(0<wbr>), I.getOperand(1),<br>+                               <wbr>  SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>@@ -1425,6 +1425,7 @@ Instruction *InstCombiner::visitAnd(Bina<br>   if (Value *V = SimplifyBSwap(I, Builder))<br>     return replaceInstUsesWith(I, V);<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   const APInt *C;<br>   if (match(Op1, m_APInt(C))) {<br>     Value *X, *Y;<br>@@ -2015,11 +2016,11 @@ Value *InstCombiner::foldOrOfICmps(I<wbr>CmpI<br> // here. We should standardize that construct where it is needed or choose some<br> // other way to ensure that commutated variants of patterns are not missed.<br> Instruction *InstCombiner::visitOr(BinaryO<wbr>perator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyOrInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyOrInst(I.getOperand(0)<wbr>, I.getOperand(1),<br>+                               <wbr> SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>@@ -2046,6 +2047,7 @@ Instruction *InstCombiner::visitOr(Binar<br>   if (Instruction *BSwap = MatchBSwap(I))<br>     return BSwap;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   {<br>     Value *A;<br>     const APInt *C;<br>@@ -2468,11 +2470,11 @@ static Instruction *visitMaskedMerge(Bin<br> // here. We should standardize that construct where it is needed or choose some<br> // other way to ensure that commutated variants of patterns are not missed.<br> Instruction *InstCombiner::visitXor(Binary<wbr>Operator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyXorInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyXorInst(I.getOperand(0<wbr>), I.getOperand(1),<br>+                               <wbr>  SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>@@ -2492,6 +2494,7 @@ Instruction *InstCombiner::visitXor(Bina<br>     return replaceInstUsesWith(I, V);<br><br>   // A^B --> A|B iff A and B have no bits set in common.<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (haveNoCommonBitsSet(Op0, Op1, DL, &AC, &I, &DT))<br>     return BinaryOperator::CreateOr(Op0, Op1);<br><br><br>Modified: llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineMulDivRem.c<wbr>pp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=335258&r1=335257&r2=335258&view=diff" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/InstCombine/InstCombineMulDi<wbr>vRem.cpp?rev=335258&r1=335257&<wbr>r2=335258&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineMulDivRem.c<wbr>pp (original)<br>+++ llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineMulDivRem.c<wbr>pp Thu Jun 21 10:06:36 2018<br>@@ -126,11 +126,11 @@ static Constant *getLogBase2(Type *Ty, C<br> }<br><br> Instruction *InstCombiner::visitMul(Binary<wbr>Operator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyMulInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyMulInst(I.getOperand(0<wbr>), I.getOperand(1),<br>+                               <wbr>  SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>@@ -138,6 +138,7 @@ Instruction *InstCombiner::visitMul(Bina<br>     return replaceInstUsesWith(I, V);<br><br>   // X * -1 == 0 - X<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (match(Op1, m_AllOnes())) {<br>     BinaryOperator *BO = BinaryOperator::CreateNeg(Op0, I.getName());<br>     if (I.hasNoSignedWrap())<br>@@ -406,12 +407,12 @@ Instruction *InstCombiner::visitMul(Bina<br> }<br><br> Instruction *InstCombiner::visitFMul(Binar<wbr>yOperator &I) {<br>-  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyFMulInst(Op0, Op1, I.getFastMathFlags(),<br>+  if (Value *V = SimplifyFMulInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   I.getFastMathFlags(),<br>                               <wbr>    SQ.getWithInstruction(&I))<wbr>)<br>     return replaceInstUsesWith(I, V);<br><br>+  bool Changed = SimplifyAssociativeOrCommutati<wbr>ve(I);<br>   if (Instruction *X = foldShuffledBinop(I))<br>     return X;<br><br>@@ -419,6 +420,7 @@ Instruction *InstCombiner::visitFMul(Bin<br>     return FoldedMul;<br><br>   // X * -1.0 --> -X<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (match(Op1, m_SpecificFP(-1.0)))<br>     return BinaryOperator::CreateFNegFMF(<wbr>Op0, &I);<br><br>@@ -936,8 +938,8 @@ static Instruction *narrowUDivURem(Binar<br> }<br><br> Instruction *InstCombiner::visitUDiv(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyUDivInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyUDivInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -948,6 +950,7 @@ Instruction *InstCombiner::visitUDiv(Bin<br>     return Common;<br><br>   // (x lshr C1) udiv C2 --> x udiv (C2 << C1)<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   {<br>     Value *X;<br>     const APInt *C1, *C2;<br>@@ -1004,8 +1007,8 @@ Instruction *InstCombiner::visitUDiv(Bin<br> }<br><br> Instruction *InstCombiner::visitSDiv(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifySDivInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifySDivInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -1015,6 +1018,7 @@ Instruction *InstCombiner::visitSDiv(Bin<br>   if (Instruction *Common = commonIDivTransforms(I))<br>     return Common;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   const APInt *Op1C;<br>   if (match(Op1, m_APInt(Op1C))) {<br>     // sdiv X, -1 == -X<br>@@ -1147,8 +1151,8 @@ static Instruction *foldFDivConstantDivi<br> }<br><br> Instruction *InstCombiner::visitFDiv(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyFDivInst(Op0, Op1, I.getFastMathFlags(),<br>+  if (Value *V = SimplifyFDivInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   I.getFastMathFlags(),<br>                               <wbr>    SQ.getWithInstruction(&I))<wbr>)<br>     return replaceInstUsesWith(I, V);<br><br>@@ -1161,6 +1165,7 @@ Instruction *InstCombiner::visitFDiv(Bin<br>   if (Instruction *R = foldFDivConstantDividend(I))<br>     return R;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (isa<Constant>(Op0))<br>     if (SelectInst *SI = dyn_cast<SelectInst>(Op1))<br>       if (Instruction *R = FoldOpIntoSelect(I, SI))<br>@@ -1276,8 +1281,8 @@ Instruction *InstCombiner::commonIRemTra<br> }<br><br> Instruction *InstCombiner::visitURem(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyURemInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyURemInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -1290,6 +1295,7 @@ Instruction *InstCombiner::visitURem(Bin<br>     return NarrowRem;<br><br>   // X urem Y -> X and Y-1, where Y is a power of 2,<br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   if (isKnownToBeAPowerOfTwo(Op1, /*OrZero*/ true, 0, &I)) {<br>     Constant *N1 = Constant::getAllOnesValue(I.ge<wbr>tType());<br>     Value *Add = Builder.CreateAdd(Op1, N1);<br>@@ -1314,8 +1320,8 @@ Instruction *InstCombiner::visitURem(Bin<br> }<br><br> Instruction *InstCombiner::visitSRem(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifySRemInst(Op0, Op1, SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifySRemInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -1325,6 +1331,7 @@ Instruction *InstCombiner::visitSRem(Bin<br>   if (Instruction *Common = commonIRemTransforms(I))<br>     return Common;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   {<br>     const APInt *Y;<br>     // X % -Y -> X % Y<br>@@ -1386,8 +1393,8 @@ Instruction *InstCombiner::visitSRem(Bin<br> }<br><br> Instruction *InstCombiner::visitFRem(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V = SimplifyFRemInst(Op0, Op1, I.getFastMathFlags(),<br>+  if (Value *V = SimplifyFRemInst(I.getOperand(<wbr>0), I.getOperand(1),<br>+                               <wbr>   I.getFastMathFlags(),<br>                               <wbr>    SQ.getWithInstruction(&I))<wbr>)<br>     return replaceInstUsesWith(I, V);<br><br><br>Modified: llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineShifts.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=335258&r1=335257&r2=335258&view=diff" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/InstCombine/InstCombineShift<wbr>s.cpp?rev=335258&r1=335257&r2=<wbr>335258&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineShifts.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineShifts.cpp Thu Jun 21 10:06:36 2018<br>@@ -588,10 +588,9 @@ Instruction *InstCombiner::FoldShiftByCo<br> }<br><br> Instruction *InstCombiner::visitShl(Binary<wbr>Operator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V =<br>-          SimplifyShlInst(Op0, Op1, I.hasNoSignedWrap(), I.hasNoUnsignedWrap(),<br>-                          SQ.ge<wbr>tWithInstruction(&I)))<br>+  if (Value *V = SimplifyShlInst(I.getOperand(0<wbr>), I.getOperand(1),<br>+                               <wbr>  I.hasNoSignedWrap(), I.hasNoUnsignedWrap(),<br>+                               <wbr>  SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -600,11 +599,12 @@ Instruction *InstCombiner::visitShl(Bina<br>   if (Instruction *V = commonShiftTransforms(I))<br>     return V;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   Type *Ty = I.getType();<br>   const APInt *ShAmtAPInt;<br>   if (match(Op1, m_APInt(ShAmtAPInt))) {<br>     unsigned ShAmt = ShAmtAPInt->getZExtValue();<br>-    unsigned BitWidth = I.getType()->getScalarSizeInBi<wbr>ts();<br>+    unsigned BitWidth = Ty->getScalarSizeInBits();<br><br>     // shl (zext X), ShAmt --> zext (shl X, ShAmt)<br>     // This is only valid if X would have zeros shifted out.<br>@@ -693,9 +693,8 @@ Instruction *InstCombiner::visitShl(Bina<br> }<br><br> Instruction *InstCombiner::visitLShr(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V =<br>-          SimplifyLShrInst(Op0, Op1, I.isExact(), SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyLShrInst(I.getOperand(<wbr>0), I.getOperand(1), I.isExact(),<br>+                               <wbr>   SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -704,6 +703,7 @@ Instruction *InstCombiner::visitLShr(Bin<br>   if (Instruction *R = commonShiftTransforms(I))<br>     return R;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   Type *Ty = I.getType();<br>   const APInt *ShAmtAPInt;<br>   if (match(Op1, m_APInt(ShAmtAPInt))) {<br>@@ -821,9 +821,8 @@ Instruction *InstCombiner::visitLShr(Bin<br> }<br><br> Instruction *InstCombiner::visitAShr(Binar<wbr>yOperator &I) {<br>-  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>-  if (Value *V =<br>-          SimplifyAShrInst(Op0, Op1, I.isExact(), SQ.getWithInstruction(&I)))<br>+  if (Value *V = SimplifyAShrInst(I.getOperand(<wbr>0), I.getOperand(1), I.isExact(),<br>+                               <wbr>   SQ.getWithInstruction(&I)))<br>     return replaceInstUsesWith(I, V);<br><br>   if (Instruction *X = foldShuffledBinop(I))<br>@@ -832,6 +831,7 @@ Instruction *InstCombiner::visitAShr(Bin<br>   if (Instruction *R = commonShiftTransforms(I))<br>     return R;<br><br>+  Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);<br>   Type *Ty = I.getType();<br>   unsigned BitWidth = Ty->getScalarSizeInBits();<br>   const APInt *ShAmtAPInt;<br><br><br>______________________________<wbr>_________________<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" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>