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