[PATCH] D12136: [X86] Emit more efficient >= comparisons against 0

Mitch Bodart via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 09:53:38 PDT 2015


mbodart added inline comments.

================
Comment at: lib/Target/X86/X86ISelLowering.cpp:24077
@@ -24076,1 +24076,3 @@
 
+static SDValue foldXorTruncShiftIntoCmp(SDNode *N, SelectionDAG &DAG) {
+  // This is only worth doing if the output type is i8.
----------------
It would be nice to have a brief comment here describing the general pattern.
Something like:

Attempt to transform signedness tests similar to (i8)(X >= 0), appearing in DAG form
as for example  (xor i8  trunc(A i32 >> 31), 1), into setcc A SETGT -1.

================
Comment at: lib/Target/X86/X86ISelLowering.cpp:24078
@@ +24077,3 @@
+static SDValue foldXorTruncShiftIntoCmp(SDNode *N, SelectionDAG &DAG) {
+  // This is only worth doing if the output type is i8.
+  if (N->getValueType(0) != MVT::i8)
----------------
I would think we also want to suppress this if the xor has more than one user.

================
Comment at: lib/Target/X86/X86ISelLowering.cpp:24113
@@ +24112,3 @@
+  SDValue Cond = DAG.getSetCC(DL, MVT::i8, ShiftOp,
+                              DAG.getConstant(-1, DL, ShiftOpTy), ISD::SETGT);
+  return Cond;
----------------
This is fine.  But just curious, is there a reason you chose SETGT -1 over SETGE 0?


http://reviews.llvm.org/D12136





More information about the llvm-commits mailing list