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