[llvm] [RISCV][P-ext] Add packed sign and zero extend intrinsics (PR #208685)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 08:11:05 PDT 2026


================
@@ -6527,6 +6544,15 @@ SDValue RISCVTargetLowering::lowerVECTOR_SHUFFLE(SDValue Op,
   if (Subtarget.hasStdExtP() && !Subtarget.hasVInstructions()) {
     ArrayRef<int> Mask = SVN->getMask();
 
+    // shuffle(src, zero, <0, N, 2, N+2, ...>) is a packed zero-extend:
+    // PPAIRE(src, 0). XformToShuffleWithZero forms this from an `and` with a
+    // low-half mask (see isVectorClearMaskLegal).
+    if (ISD::isConstantSplatVectorAllZeros(V2.getNode()) &&
+        isPackedZExtShuffleMask(Mask))
+      return DAG.getNode(RISCVISD::PPAIRE, DL, VT, V1,
----------------
sihuan wrote:

Consolidated in 7b65b6dd. `XformToShuffleWithZero` leaves each zeroed lane at its own position, so it produces the mask `<0, 5, 2, 7>` rather than the strided `<0, 4, 2, 6>` that `lowerVECTOR_SHUFFLEAsPPair` matched — that's why it needed a separate path. But the second operand is a zero splat, so any lane selecting from it is a wildcard and the two masks are equivalent. I generalized `lowerVECTOR_SHUFFLEAsPPair` to treat a splat operand's lanes as wildcards, which folds the zero-extend case into it and drops the special-case block.

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


More information about the llvm-commits mailing list