[PATCH] D103820: Prefer vpmovq2m over vpternlogd + vpcmpgtq

David Zarzycki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 08:26:48 PDT 2021


davezarzycki created this revision.
davezarzycki added reviewers: craig.topper, spatel.
davezarzycki added a project: LLVM.
Herald added subscribers: pengfei, hiraditya.
davezarzycki requested review of this revision.

Let's undo earlier optimizations that turn < 0 comparisons into > -1. This enables us to use vpmovq2m instead of vpternlogd + vpcmpgtq.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103820

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -22797,6 +22797,12 @@
     std::swap(Op0, Op1);
   }
 
+  // Prefer < 0 over > -1.
+  if (SetCCOpcode == ISD::SETGT && ISD::isBuildVectorAllOnes(Op1.getNode())) {
+    SetCCOpcode = ISD::SETLT;
+    Op1 = DAG.getConstant(0, dl, Op1.getValueType());
+  }
+
   return DAG.getSetCC(dl, VT, Op0, Op1, SetCCOpcode);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103820.350305.patch
Type: text/x-patch
Size: 522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210607/f5c95ed9/attachment.bin>


More information about the llvm-commits mailing list