Lower unsigned vsetcc to psubus in certain cases
authorQuentin Colombet <qcolombet@apple.com>
Wed, 26 Feb 2014 21:39:12 +0000 (21:39 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Wed, 26 Feb 2014 21:39:12 +0000 (21:39 +0000)
commit685b0d9315c0e4305113e8a92b1891908c3f5fe6
tree92c7f9337edf2a441446385d0fe30cbfc063c5f1
parentc540920a247aefd90bf5c79d4969ed9a963bd3f1
Lower unsigned vsetcc to psubus in certain cases

The current approach to lower a vsetult is to flip the sign bit of the
operands, swap the operands and then use a (signed) pcmpgt.  psubus (unsigned
saturating subtract) can be used to emulate a vsetult more efficiently:

+    case ISD::SETULT: {
+      // If the comparison is against a constant we can turn this into a
+      // setule.  With psubus, setule does not require a swap.  This is
+      // beneficial because the constant in the register is no longer
+      // destructed as the destination so it can be hoisted out of a loop.

I also enable lowering via psubus in a few other cases where it's clearly
beneficial: setule and setuge if minu/maxu cannot be used.

rdar://problem/14338765

Patch by Adam Nemet <anemet@apple.com>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202301 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/vec_setcc-2.ll [new file with mode: 0644]
test/CodeGen/X86/vec_setcc.ll