[PATCH] [CodeGen] Add hooks/combine to form vector extloads, and enable it on X86.

Chandler Carruth chandlerc at gmail.com
Fri Jan 9 13:40:55 PST 2015


Wow this looks amazing. I'm glad you were able to make it all the way through to fixing this properly (I wasn't when I looked here, I ran away screaming).

Some comments inline...


================
Comment at: include/llvm/Target/TargetLowering.h:1512
@@ +1511,3 @@
+  /// Return true if folding a load into ExtVal is profitable.
+  virtual bool isVectorExtLdDesirable(SDValue ExtVal) const {
+    return false;
----------------
Do we you "ExtLd" in APIs elsewhere? this kind of extreme abbreviation, especially if deviating from other abbreviations, makes the APIs really hard to understand and find.

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5660
@@ -5598,1 +5659,3 @@
 
+  // fold (zext (load x)) -> (zext (truncate (zextload x)))
+  // Only on illegal but splittable vectors.
----------------
This code is extremely similar to the sext case. Can it be factored out with an appropriate predicate or input instruction tag or something?

================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:5665-5671
@@ +5664,9 @@
+      (!LegalOperations && !cast<LoadSDNode>(N0)->isVolatile())) {
+    bool DoXform = true;
+    SmallVector<SDNode *, 4> SetCCs;
+    if (VT.isVector())
+      DoXform = TLI.isVectorExtLdDesirable(SDValue(N, 0));
+    if (!N0.hasOneUse())
+      DoXform = ExtendUsesToFormExtLoad(N, N0, ISD::ZERO_EXTEND, SetCCs, TLI);
+    if (DoXform) {
+      LoadSDNode *LN0 = cast<LoadSDNode>(N0);
----------------
Even if you can't put this into a common function with sext, at least pull both into their own functions so that you can use early exit for all of this rather than boolean variables.

================
Comment at: test/CodeGen/X86/widen_load-2.ll:76-79
@@ -75,4 +75,6 @@
 ; CHECK-LABEL: add3i16:
-; CHECK:         pmovzxwd (%{{.*}}), %[[R0:xmm[0-9]+]]
-; CHECK-NEXT:    pmovzxwd (%{{.*}}), %[[R1:xmm[0-9]+]]
+; CHECK:         movq     (%rsi), %xmm0
+; CHECK-NEXT:    pmovzxwd %xmm0, %xmm0
+; CHECK-NEXT:    movq     (%rdx), %xmm1
+; CHECK-NEXT:    pmovzxwd %xmm1, %xmm1
 ; CHECK-NEXT:    paddd    %[[R0]], %[[R1]]
----------------
This is both weird and unfortunate... Do understand why this happens?

http://reviews.llvm.org/D6904

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list