<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=""> Thanks<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 4, 2018, at 4:19 AM, Maxim Kazantsev <<a href="mailto:max.kazantsev@azul.com" class="">max.kazantsev@azul.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration: none;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><a href="https://reviews.llvm.org/D48930" style="color: purple; text-decoration: underline;" class="">https://reviews.llvm.org/D48930</a></span><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><span class="Apple-converted-space"> </span>should help.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><b class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="Apple-converted-space"> </span>Maxim Kazantsev<span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Wednesday, July 4, 2018 1:49 PM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>'<a href="mailto:aditya_nandakumar@apple.com" style="color: purple; text-decoration: underline;" class="">aditya_nandakumar@apple.com</a>' <<a href="mailto:aditya_nandakumar@apple.com" style="color: purple; text-decoration: underline;" class="">aditya_nandakumar@apple.com</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span>'<a href="mailto:llvm-commits@lists.llvm.org" style="color: purple; text-decoration: underline;" class="">llvm-commits@lists.llvm.org</a>' <<a href="mailto:llvm-commits@lists.llvm.org" style="color: purple; text-decoration: underline;" class="">llvm-commits@lists.llvm.org</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>RE: [llvm] r336172 - [InstCombine] Delay foldICmpUsingKnownBits until simple transforms are done<o:p class=""></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">The root cause is that we kill *all* further transforms with this code.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // Test if the ICmpInst instruction is used exclusively by a select as<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // part of a minimum or maximum operation. If so, refrain from doing<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // any other folding. This helps out other analyses which understand<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // non-obfuscated minimum and maximum idioms, such as ScalarEvolution<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // and CodeGen. And in this case, at least one of the comparison<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // operands has at least one user besides the compare (the select),<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // which would often largely negate the benefit of folding anyway.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  //<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  // Do the same for the other patterns recognized by matchSelectPattern.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">  if (I.hasOneUse())<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">    if (SelectInst *SI = dyn_cast<SelectInst>(I.user_back())) {<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">      Value *A, *B;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">      SelectPatternResult SPR = matchSelectPattern(SI, A, B);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">      if (SPR.Flavor != SPF_UNKNOWN)<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">        return nullptr;<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">    }<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">It looks at least unreasonable. I will try to fix that.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">-- Max<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><b class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="Apple-converted-space"> </span>Maxim Kazantsev<span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Wednesday, July 4, 2018 12:27 PM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>'<a href="mailto:aditya_nandakumar@apple.com" style="color: purple; text-decoration: underline;" class="">aditya_nandakumar@apple.com</a>' <<a href="mailto:aditya_nandakumar@apple.com" style="color: purple; text-decoration: underline;" class="">aditya_nandakumar@apple.com</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@lists.llvm.org" style="color: purple; text-decoration: underline;" class="">llvm-commits@lists.llvm.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>RE: [llvm] r336172 - [InstCombine] Delay foldICmpUsingKnownBits until simple transforms are done<o:p class=""></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Hi Aditya,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">Thanks for the test, I'll see what's happening with it.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class="">-- Max<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);" class=""><o:p class=""> </o:p></span></div><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><b class=""><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class="">From:</span></b><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span class="Apple-converted-space"> </span><a href="mailto:aditya_nandakumar@apple.com" style="color: purple; text-decoration: underline;" class="">aditya_nandakumar@apple.com</a><span class="Apple-converted-space"> </span>[<a href="mailto:aditya_nandakumar@apple.com" style="color: purple; text-decoration: underline;" class="">mailto:aditya_nandakumar@apple.com</a>]<span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Wednesday, July 4, 2018 6:57 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Maxim Kazantsev <<a href="mailto:max.kazantsev@azul.com" style="color: purple; text-decoration: underline;" class="">max.kazantsev@azul.com</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@lists.llvm.org" style="color: purple; text-decoration: underline;" class="">llvm-commits@lists.llvm.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [llvm] r336172 - [InstCombine] Delay foldICmpUsingKnownBits until simple transforms are done<o:p class=""></o:p></span></div></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman", serif;" class=""><o:p class=""> </o:p></div><div class=""><div class=""><p class="MsoNormal" style="margin: 0cm 0cm 12pt; font-size: 12pt; font-family: "Times New Roman", serif;"><span style="font-size: 10pt;" class="">Hi Max<br class=""><br class="">This commit is causing significantly worse codegen similar to what’s seen in this simplified test case.<o:p class=""></o:p></span></p></div></div><div class=""><div class=""><p class="MsoNormal" style="margin: 0cm 0cm 12pt; font-size: 12pt; font-family: "Times New Roman", serif;"><span style="font-size: 10pt;" class=""><br class=""><br class="">Previously we produce<br class="">define i16 @foo(i16) {<br class="">entry:<br class="">  %1 = and i16 %0, 255<br class="">  ret i16 %1<br class="">}<br class=""><br class="">With this commit, instcombine doesn’t seem to change the input at all.<br class=""><br class="">Could you please take a look at this ?<br class=""><br class="">Aditya<br class=""><br class="">> On Jul 2, 2018, at 11:23 PM, Max Kazantsev via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" style="color: purple; text-decoration: underline;" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class="">><span class="Apple-converted-space"> </span><br class="">> Author: mkazantsev<br class="">> Date: Mon Jul  2 23:23:57 2018<br class="">> New Revision: 336172<br class="">><span class="Apple-converted-space"> </span><br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=336172&view=rev" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project?rev=336172&view=rev</a><br class="">> Log:<br class="">> [InstCombine] Delay foldICmpUsingKnownBits until simple transforms are done<br class="">><span class="Apple-converted-space"> </span><br class="">> This patch changes order of transform in InstCombineCompares to avoid<br class="">> performing transforms based on ranges which produce complex bit arithmetics<br class="">> before more simple things (like folding with constants) are done. See PR37636<br class="">> for the motivating example.<br class="">><span class="Apple-converted-space"> </span><br class="">> Differential Revision:<span class="Apple-converted-space"> </span><a href="https://reviews.llvm.org/D48584" style="color: purple; text-decoration: underline;" class="">https://reviews.llvm.org/D48584</a><br class="">> Reviewed By: spatel, lebedev.ri<br class="">><span class="Apple-converted-space"> </span><br class="">> Modified:<br class="">>    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp<br class="">>    llvm/trunk/test/Analysis/ValueTracking/non-negative-phi-bits.ll<br class="">>    llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll<br class="">>    llvm/trunk/test/Transforms/InstCombine/icmp-shr-lt-gt.ll<br class="">>    llvm/trunk/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll<br class="">>    llvm/trunk/test/Transforms/LoopVectorize/X86/masked_load_store.ll<br class="">><span class="Apple-converted-space"> </span><br class="">> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp<br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=336172&r1=336171&r2=336172&view=diff" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=336172&r1=336171&r2=336172&view=diff</a><br class="">> ==============================================================================<br class="">> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)<br class="">> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul  2 23:23:57 2018<br class="">> @@ -4485,9 +4485,6 @@ Instruction *InstCombiner::visitICmpInst<br class="">>   if (Instruction *Res = foldICmpWithConstant(I))<br class="">>     return Res;<br class="">><span class="Apple-converted-space"> </span><br class="">> -  if (Instruction *Res = foldICmpUsingKnownBits(I))<br class="">> -    return Res;<br class="">> -<br class="">>   // Test if the ICmpInst instruction is used exclusively by a select as<br class="">>   // part of a minimum or maximum operation. If so, refrain from doing<br class="">>   // any other folding. This helps out other analyses which understand<br class="">> @@ -4706,6 +4703,13 @@ Instruction *InstCombiner::visitICmpInst<br class="">>     if (match(Op1, m_Add(m_Value(X), m_ConstantInt(Cst))) && Op0 == X)<br class="">>       return foldICmpAddOpConst(X, Cst, I.getSwappedPredicate());<br class="">>   }<br class="">> +<br class="">> +  // This may be expensive in compile-time, and transforms based on known bits<br class="">> +  // can make further analysis more difficult, so we use it as the last resort<br class="">> +  // if we cannot do anything better.<br class="">> +  if (Instruction *Res = foldICmpUsingKnownBits(I))<br class="">> +    return Res;<br class="">> +<br class="">>   return Changed ? &I : nullptr;<br class="">> }<br class="">><span class="Apple-converted-space"> </span><br class="">><span class="Apple-converted-space"> </span><br class="">> Modified: llvm/trunk/test/Analysis/ValueTracking/non-negative-phi-bits.ll<br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ValueTracking/non-negative-phi-bits.ll?rev=336172&r1=336171&r2=336172&view=diff" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ValueTracking/non-negative-phi-bits.ll?rev=336172&r1=336171&r2=336172&view=diff</a><br class="">> ==============================================================================<br class="">> --- llvm/trunk/test/Analysis/ValueTracking/non-negative-phi-bits.ll (original)<br class="">> +++ llvm/trunk/test/Analysis/ValueTracking/non-negative-phi-bits.ll Mon Jul  2 23:23:57 2018<br class="">> @@ -8,7 +8,7 @@ define void @test() #0 {<br class="">> ; CHECK:       for.body:<br class="">> ; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]<br class="">> ; CHECK-NEXT:    [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1<br class="">> -; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ult i64 [[INDVARS_IV_NEXT]], 40<br class="">> +; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ult i64 [[INDVARS_IV]], 39<br class="">> ; CHECK-NEXT:    br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]<br class="">> ; CHECK:       for.end:<br class="">> ; CHECK-NEXT:    ret void<br class="">><span class="Apple-converted-space"> </span><br class="">> Modified: llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll<br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll?rev=336172&r1=336171&r2=336172&view=diff" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll?rev=336172&r1=336171&r2=336172&view=diff</a><br class="">> ==============================================================================<br class="">> --- llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll (original)<br class="">> +++ llvm/trunk/test/Transforms/InstCombine/icmp-shl-nsw.ll Mon Jul  2 23:23:57 2018<br class="">> @@ -69,11 +69,9 @@ define <2 x i1> @icmp_shl_nsw_eq_vec(<2<br class="">> ; icmp sgt with shl nsw with a constant compare operand and constant<br class="">> ; shift amount can always be reduced to icmp sgt alone.<br class="">><span class="Apple-converted-space"> </span><br class="">> -; Known bits analysis turns this into an equality predicate.<br class="">> -<br class="">> define i1 @icmp_sgt1(i8 %x) {<br class="">> ; CHECK-LABEL: @icmp_sgt1(<br class="">> -; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 %x, -64<br class="">> +; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 %x, -64<br class="">> ; CHECK-NEXT:    ret i1 [[CMP]]<br class="">> ;<br class="">>   %shl = shl nsw i8 %x, 1<br class="">> @@ -144,11 +142,10 @@ define i1 @icmp_sgt7(i8 %x) {<br class="">>   ret i1 %cmp<br class="">> }<br class="">><span class="Apple-converted-space"> </span><br class="">> -; Known bits analysis turns this into an equality predicate.<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @icmp_sgt8(i8 %x) {<br class="">> ; CHECK-LABEL: @icmp_sgt8(<br class="">> -; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 %x, 63<br class="">> +; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 %x, 62<br class="">> ; CHECK-NEXT:    ret i1 [[CMP]]<br class="">> ;<br class="">>   %shl = shl nsw i8 %x, 1<br class="">> @@ -158,11 +155,9 @@ define i1 @icmp_sgt8(i8 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> ; Compares with 126 and 127 are recognized as always false.<br class="">><span class="Apple-converted-space"> </span><br class="">> -; Known bits analysis turns this into an equality predicate.<br class="">> -<br class="">> define i1 @icmp_sgt9(i8 %x) {<br class="">> ; CHECK-LABEL: @icmp_sgt9(<br class="">> -; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 %x, -1<br class="">> +; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i8 %x, -1<br class="">> ; CHECK-NEXT:    ret i1 [[CMP]]<br class="">> ;<br class="">>   %shl = shl nsw i8 %x, 7<br class="">> @@ -210,11 +205,9 @@ define <2 x i1> @icmp_sgt11_vec(<2 x i8><br class="">> ;<br class="">> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br class="">><span class="Apple-converted-space"> </span><br class="">> -; Known bits analysis turns this into an equality predicate.<br class="">> -<br class="">> define i1 @icmp_sle1(i8 %x) {<br class="">> ; CHECK-LABEL: @icmp_sle1(<br class="">> -; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 %x, -64<br class="">> +; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i8 %x, -63<br class="">> ; CHECK-NEXT:    ret i1 [[CMP]]<br class="">> ;<br class="">>   %shl = shl nsw i8 %x, 1<br class="">> @@ -285,11 +278,9 @@ define i1 @icmp_sle7(i8 %x) {<br class="">>   ret i1 %cmp<br class="">> }<br class="">><span class="Apple-converted-space"> </span><br class="">> -; Known bits analysis turns this into an equality predicate.<br class="">> -<br class="">> define i1 @icmp_sle8(i8 %x) {<br class="">> ; CHECK-LABEL: @icmp_sle8(<br class="">> -; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i8 %x, 63<br class="">> +; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i8 %x, 63<br class="">> ; CHECK-NEXT:    ret i1 [[CMP]]<br class="">> ;<br class="">>   %shl = shl nsw i8 %x, 1<br class="">> @@ -299,11 +290,9 @@ define i1 @icmp_sle8(i8 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> ; Compares with 126 and 127 are recognized as always true.<br class="">><span class="Apple-converted-space"> </span><br class="">> -; Known bits analysis turns this into an equality predicate.<br class="">> -<br class="">> define i1 @icmp_sle9(i8 %x) {<br class="">> ; CHECK-LABEL: @icmp_sle9(<br class="">> -; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 %x, -1<br class="">> +; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i8 %x, 0<br class="">> ; CHECK-NEXT:    ret i1 [[CMP]]<br class="">> ;<br class="">>   %shl = shl nsw i8 %x, 7<br class="">> @@ -353,4 +342,3 @@ define i1 @icmp_ne1(i8 %x) {<br class="">>   %cmp = icmp ne i8 %shl, -128<br class="">>   ret i1 %cmp<br class="">> }<br class="">> -<br class="">><span class="Apple-converted-space"> </span><br class="">> Modified: llvm/trunk/test/Transforms/InstCombine/icmp-shr-lt-gt.ll<br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-shr-lt-gt.ll?rev=336172&r1=336171&r2=336172&view=diff" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp-shr-lt-gt.ll?rev=336172&r1=336171&r2=336172&view=diff</a><br class="">> ==============================================================================<br class="">> --- llvm/trunk/test/Transforms/InstCombine/icmp-shr-lt-gt.ll (original)<br class="">> +++ llvm/trunk/test/Transforms/InstCombine/icmp-shr-lt-gt.ll Mon Jul  2 23:23:57 2018<br class="">> @@ -1,3 +1,4 @@<br class="">> +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py<br class="">> ; RUN: opt < %s -instcombine -S | FileCheck %s<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrugt_01_00(i4 %x) {<br class="">> @@ -1834,7 +1835,7 @@ define i1 @lshrugt_01_05_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrugt_01_06_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrugt_01_06_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp eq i4 %x, -2<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ugt i4 %x, -4<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 1<br class="">> @@ -1945,7 +1946,7 @@ define i1 @lshrugt_02_01_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrugt_02_02_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrugt_02_02_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp eq i4 %x, -4<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ugt i4 %x, -8<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 2<br class="">> @@ -2226,7 +2227,7 @@ define i1 @lshrult_01_00_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrult_01_01_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrult_01_01_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp eq i4 %x, 0<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ult i4 %x, 2<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 1<br class="">> @@ -2286,7 +2287,7 @@ define i1 @lshrult_01_06_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrult_01_07_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrult_01_07_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp ne i4 %x, -2<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ult i4 %x, -2<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 1<br class="">> @@ -2377,7 +2378,7 @@ define i1 @lshrult_02_00_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrult_02_01_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrult_02_01_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp eq i4 %x, 0<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ult i4 %x, 4<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 2<br class="">> @@ -2397,7 +2398,7 @@ define i1 @lshrult_02_02_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrult_02_03_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrult_02_03_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp ne i4 %x, -4<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ult i4 %x, -4<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 2<br class="">> @@ -2524,7 +2525,7 @@ define i1 @lshrult_03_00_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @lshrult_03_01_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @lshrult_03_01_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp ne i4 %x, -8<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp sgt i4 %x, -1<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = lshr exact i4 %x, 3<br class="">> @@ -2801,7 +2802,7 @@ define i1 @ashrsgt_01_14_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @ashrsgt_01_15_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @ashrsgt_01_15_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp sgt i4 %x, -1<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp sgt i4 %x, -2<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = ashr exact i4 %x, 1<br class="">> @@ -2948,7 +2949,7 @@ define i1 @ashrsgt_02_14_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @ashrsgt_02_15_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @ashrsgt_02_15_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp sgt i4 %x, -1<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp sgt i4 %x, -4<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = ashr exact i4 %x, 2<br class="">> @@ -3093,7 +3094,7 @@ define i1 @ashrsgt_03_14_exact(i4 %x) {<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @ashrsgt_03_15_exact(i4 %x) {<br class="">> ; CHECK-LABEL: @ashrsgt_03_15_exact(<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp sgt i4 %x, -1<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ne i4 %x, -8<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %s = ashr exact i4 %x, 3<br class="">><span class="Apple-converted-space"> </span><br class="">> Modified: llvm/trunk/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll<br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll?rev=336172&r1=336171&r2=336172&view=diff" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll?rev=336172&r1=336171&r2=336172&view=diff</a><br class="">> ==============================================================================<br class="">> --- llvm/trunk/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll (original)<br class="">> +++ llvm/trunk/test/Transforms/InstCombine/icmp_sdiv_with_and_without_range.ll Mon Jul  2 23:23:57 2018<br class="">> @@ -2,7 +2,8 @@<br class="">> ; RUN: opt -instcombine -S < %s | FileCheck %s<br class="">><span class="Apple-converted-space"> </span><br class="">> ; Test that presence of range does not cause unprofitable transforms with bit<br class="">> -; arithmetics, and instcombine behaves exactly the same as without the range.<br class="">> +; arithmetics. InstCombine needs to be smart about dealing with range-annotated<br class="">> +; values.<br class="">><span class="Apple-converted-space"> </span><br class="">> define i1 @without_range(i32* %A) {<br class="">> ; CHECK-LABEL: @without_range(<br class="">> @@ -19,8 +20,7 @@ define i1 @without_range(i32* %A) {<br class="">> define i1 @with_range(i32* %A) {<br class="">> ; CHECK-LABEL: @with_range(<br class="">> ; CHECK-NEXT:    [[A_VAL:%.*]] = load i32, i32* [[A:%.*]], align 8, !range !0<br class="">> -; CHECK-NEXT:    [[B_MASK:%.*]] = and i32 [[A_VAL]], 2147483646<br class="">> -; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[B_MASK]], 0<br class="">> +; CHECK-NEXT:    [[C:%.*]] = icmp ult i32 [[A_VAL]], 2<br class="">> ; CHECK-NEXT:    ret i1 [[C]]<br class="">> ;<br class="">>   %A.val = load i32, i32* %A, align 8, !range !0<br class="">><span class="Apple-converted-space"> </span><br class="">> Modified: llvm/trunk/test/Transforms/LoopVectorize/X86/masked_load_store.ll<br class="">> URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/X86/masked_load_store.ll?rev=336172&r1=336171&r2=336172&view=diff" style="color: purple; text-decoration: underline;" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/X86/masked_load_store.ll?rev=336172&r1=336171&r2=336172&view=diff</a><br class="">> ==============================================================================<br class="">> --- llvm/trunk/test/Transforms/LoopVectorize/X86/masked_load_store.ll (original)<br class="">> +++ llvm/trunk/test/Transforms/LoopVectorize/X86/masked_load_store.ll Mon Jul  2 23:23:57 2018<br class="">> @@ -2052,8 +2052,7 @@ define void @foo4(double* %A, double* %B<br class="">> ; AVX512-NEXT:    [[PROL_ITER_CMP:%.*]] = icmp eq i64 [[PROL_ITER_SUB]], 0<br class="">> ; AVX512-NEXT:    br i1 [[PROL_ITER_CMP]], label [[FOR_BODY_PROL_LOOPEXIT:%.*]], label [[FOR_BODY_PROL]], !llvm.loop !50<br class="">> ; AVX512:       for.body.prol.loopexit:<br class="">> -; AVX512-NEXT:    [[DOTMASK:%.*]] = and i64 [[TMP24]], 9984<br class="">> -; AVX512-NEXT:    [[TMP28:%.*]] = icmp eq i64 [[DOTMASK]], 0<br class="">> +; AVX512-NEXT:    [[TMP28:%.*]] = icmp ult i64 [[TMP24]], 48<br class="">> ; AVX512-NEXT:    br i1 [[TMP28]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]]<br class="">> ; AVX512:       for.body:<br class="">> ; AVX512-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT_3:%.*]], [[FOR_INC_3:%.*]] ], [ [[INDVARS_IV_NEXT_PROL]], [[FOR_BODY_PROL_LOOPEXIT]] ]<br class="">><span class="Apple-converted-space"> </span><br class="">><span class="Apple-converted-space"> </span><br class="">> _______________________________________________<br class="">> llvm-commits mailing list<br class="">><span class="Apple-converted-space"> </span><a href="mailto:llvm-commits@lists.llvm.org" style="color: purple; text-decoration: underline;" class="">llvm-commits@lists.llvm.org</a><br class="">><span class="Apple-converted-space"> </span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" style="color: purple; text-decoration: underline;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><o:p class=""></o:p></span></p></div></div></div></div></blockquote></div><br class=""></body></html>