<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 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        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;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi James,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">That is right, for Uint_max the current comparison will not be proper.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">With larger data type do you mean promoting the given data type to larger type ex: MVT:i32 to MVT:i64<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">And then doing the expansion?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Shahid<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> James Molloy [mailto:james@jamesmolloy.co.uk]
<br>
<b>Sent:</b> Monday, August 03, 2015 1:02 AM<br>
<b>To:</b> reviews+D11678+public+e92bec0f352bb617@reviews.llvm.org; Shahid, Asghar-ahmad; james.molloy@arm.com; hfinkel@anl.gov; mzolotukhin@apple.com<br>
<b>Cc:</b> llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [PATCH] D11678: [CodeGen] Fixes *absdiff* intrinsic: LangRef doc/test case improvement and corresponding code change<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I think uabsdiff needs to be expanded using a larger data type. If we have uabsdiff(uint_max, uint_max) , a signed comparison won't return the right result unless the bitwidth is expanded, right?<br>
<br>
James<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">On Sun, 2 Aug 2015 at 08:20, Shahid <<a href="mailto:Asghar-ahmad.Shahid@amd.com">Asghar-ahmad.Shahid@amd.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">ashahid added inline comments.<br>
<br>
================<br>
Comment at: docs/LangRef.rst:10387-10390<br>
@@ -10386,6 +10386,6 @@<br>
<br>
     %sub = sub nsw <4 x i32> %a, %b<br>
-    %ispos = icmp sgt <4 x i32> %sub, <i32 -1, i32 -1, i32 -1, i32 -1><br>
+    %ispos = icmp sge <4 x i32> %sub, zeroinitializer<br>
     %neg = sub nsw <4 x i32> zeroinitializer, %sub<br>
     %1 = select <4 x i1> %ispos, <4 x i32> %sub, <4 x i32> %neg<br>
<br>
----------------<br>
mzolotukhin wrote:<br>
> What's the difference between `llvm.uabsdiff` and `llvm.sabsdiff` then?<br>
The difference is the presence of NSW flag in case of llvm.sabsdiff.<br>
<br>
================<br>
Comment at: lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp:737<br>
@@ -736,5 +736,3 @@<br>
       TLI.getSetCCResultType(DAG.getDataLayout(), *DAG.getContext(), VT), Tmp2,<br>
-      DAG.getConstant(0, dl, VT),<br>
-      DAG.getCondCode(Op->getOpcode() == ISD::SABSDIFF ? ISD::SETLT<br>
-                                                       : ISD::SETULT));<br>
+      DAG.getConstant(0, dl, VT), DAG.getCondCode(ISD::SETGE));<br>
   Tmp1 = DAG.getNode(ISD::VSELECT, dl, VT, Tmp4, Tmp1, Tmp2);<br>
----------------<br>
mzolotukhin wrote:<br>
> AFAIU, this should be `ISD::SETLE`.<br>
My bad... intention was to use Tmp1 instead of Tmp2. I will use the proper variable names to reflect the operations.<br>
<br>
================<br>
Comment at: test/CodeGen/X86/absdiff_128.ll:150-152<br>
@@ +149,5 @@<br>
+; CHECK-DAG:  psubd  %xmm1, [[SRC:%xmm[0-9]+]]<br>
+; CHECK:      pxor<br>
+; CHECK-DAG:  pxor    %xmm3, [[DST:%xmm[0-9]+]]<br>
+; CHECK-NEXT: psubd  [[SRC]], [[DST]]<br>
+; CHECK-DAG:  pcmpgtd  %xmm3, [[SRC:%xmm[0-9]+]]<br>
----------------<br>
mzolotukhin wrote:<br>
> This `CHECK-DAG` doesn't make much sense, since it's limited by `CHECK` and `CHECK-NEXT` from both sides.<br>
><br>
> Moreover, I think the right way to make the tests less bristle is to not check for everything, but just look for key instructions.<br>
> For example, we definitely expect to see `psubd`, then, maybe after several other instructions, we want to see `pcmpgt`, then we want to see `pand`, `pandn`, and `por`. Thus, I'd write this test something like this:<br>
> ```<br>
> CHECK: psubd<br>
> CHECK: pcmpgt<br>
> CHECK-DAG: pand // BTW, why do you have two `pandn` here?<br>
> CHECK-DAG: pandn<br>
> CHECK: por<br>
> CHECK: ret<br>
> ```<br>
Thanks, this is a very important input.<br>
<br>
For ISD::SETGE, X86 swaps the operand, consequently, in context of VSELECT it uses two "pandn".<br>
<br>
<br>
<br>
================<br>
Comment at: test/CodeGen/X86/absdiff_128.ll:206<br>
@@ +205,3 @@<br>
+; CHECK-NEXT:   pcmpgtd<br>
+; CHECK-NEXT:   pshufd  {{.*}}    # xmm5 = xmm4[0,0,2,2]<br>
+; CHECK-NEXT:   pcmpeqd<br>
----------------<br>
mzolotukhin wrote:<br>
> If we don't want to match any specific register here, we need to get rid of comments `# xmm5 = xmm4...` too.<br>
Ok<br>
<br>
================<br>
Comment at: test/CodeGen/X86/absdiff_256.ll:33<br>
@@ +32,3 @@<br>
+; CHECK-DAG:         psubd   %xmm6, [[SRC:%xmm[0-9]+]]<br>
+; CHECK-DAG:         pxor    %xmm5, [[DST:%xmm[0-9]+]]<br>
+; CHECK-NEXT:        psubd   [[SRC]], [[DST]]<br>
----------------<br>
mzolotukhin wrote:<br>
> This is still fragile.<br>
> Imagine that register allocator for some strange reason begins to use `xmm5` instead of `xmm6` and vice versa - this test will immediately fail.<br>
><br>
> Also, if you want to match `pxor %xmmN, %xmmN`, the correct way to write the regexp for it would be:<br>
> ```<br>
> pxor [[SOMENAME:%xmm[0-9]+]], [[SOMENAME]]<br>
> ```<br>
> This will ensure that `pxor` operates on the same register.<br>
Ok<br>
<br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D11678&d=AwMGaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=YaaMkGRD15bcNsCWacadvILqw4PIunXF17nXp6cXv1E&s=DbjbrhY1foKyQPlfZEtlYXRX9URyIf4i97Z0DzasXz4&e=" target="_blank">http://reviews.llvm.org/D11678</a><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>