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<br><div class="gmail_quote"><div dir="ltr">On Sun, 2 Aug 2015 at 08:20, Shahid <<a href="mailto:Asghar-ahmad.Shahid@amd.com">Asghar-ahmad.Shahid@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=qXr4olxTTXzAzJmioHDNZGk-pjCZ2s2JDqSbSky_2dI&s=vHzR_FXV_RWy-SAbkYM8xO5u0sRsF3FmYEJxGKNTppY&e=" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>