[PATCH] D43531: [X86] Turn setne X, signedmin into setgt X, signedmin in LowerVSETCC to avoid an invert

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 15:48:48 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL325840: [X86] Turn setne X, signedmin into setgt X, signedmin in LowerVSETCC to avoid… (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43531?vs=135149&id=135536#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43531

Files:
  llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
  llvm/trunk/test/CodeGen/X86/vector-compare-simplify.ll


Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
@@ -18099,6 +18099,15 @@
     }
   }
 
+  // If this is a SETNE against the signed minimum value, change it to SETGT.
+  // Otherwise we use PCMPEQ+invert.
+  APInt ConstValue;
+  if (Cond == ISD::SETNE &&
+      ISD::isConstantSplatVector(Op1.getNode(), ConstValue),
+      ConstValue.isMinSignedValue()) {
+    Cond = ISD::SETGT;
+  }
+
   // If both operands are known non-negative, then an unsigned compare is the
   // same as a signed compare and there's no need to flip signbits.
   // TODO: We could check for more general simplifications here since we're
Index: llvm/trunk/test/CodeGen/X86/vector-compare-simplify.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/vector-compare-simplify.ll
+++ llvm/trunk/test/CodeGen/X86/vector-compare-simplify.ll
@@ -334,3 +334,14 @@
   ret <4 x i32> %r
 }
 
+; Make sure we can efficiently handle ne smin by turning into sgt.
+define <4 x i32> @ne_smin(<4 x i32> %x) {
+; CHECK-LABEL: ne_smin:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    pcmpgtd {{.*}}(%rip), %xmm0
+; CHECK-NEXT:    retq
+  %cmp = icmp ne <4 x i32> %x, <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>
+  %r = sext <4 x i1> %cmp to <4 x i32>
+  ret <4 x i32> %r
+}
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43531.135536.patch
Type: text/x-patch
Size: 1475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180222/699f0ed8/attachment.bin>


More information about the llvm-commits mailing list