[llvm] [RISCV] Use vwadd.vx for splat vector with extension (PR #87249)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 21:18:18 PDT 2024


================
@@ -13597,17 +13597,27 @@ struct NodeExtensionHelper {
     case RISCVISD::VSEXT_VL:
     case RISCVISD::VZEXT_VL:
     case RISCVISD::FP_EXTEND_VL:
-    case ISD::SPLAT_VECTOR:
       return OrigOperand.getOperand(0);
+    case ISD::SPLAT_VECTOR: {
+      SDValue Op = OrigOperand.getOperand(0);
+      unsigned Opc = Op.getOpcode();
+      if (SupportsSExt && Opc == ISD::SIGN_EXTEND_INREG)
+        return Op.getOperand(0);
+
+      if (SupportsZExt && Opc == ISD::AND)
+        return Op.getOperand(0);
+
+      return Op;
+    }
     default:
       return OrigOperand;
     }
   }
 
   /// Check if this instance represents a splat.
   bool isSplat() const {
-    return (OrigOperand.getOpcode() == RISCVISD::VMV_V_X_VL) ||
-           (OrigOperand.getOpcode() == ISD::SPLAT_VECTOR);
+    return (OrigOperand.getOpcode() == RISCVISD::VMV_V_X_VL ||
----------------
wangpc-pp wrote:

We may don't need all the brackets here.

https://github.com/llvm/llvm-project/pull/87249


More information about the llvm-commits mailing list