[llvm] [RISCV][P-ext] Improve the codegen for pzip (PR #208479)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 09:10:12 PDT 2026


================
@@ -6314,6 +6314,36 @@ static SDValue tryWidenMaskForShuffle(SDValue Op, SelectionDAG &DAG) {
   return DAG.getBitcast(VT, DAG.getVectorShuffle(NewVT, DL, V0, V1, NewMask));
 }
 
+// Match an interleave shuffle that forms a P-extension packed zip:
+//   <a0, b0, a1, b1, ...> -> zip*p/wzip*p
+static SDValue lowerVECTOR_SHUFFLEAsPZip(ShuffleVectorSDNode *SVN,
+                                         SelectionDAG &DAG) {
+  SDValue V1 = SVN->getOperand(0);
+  SDValue V2 = SVN->getOperand(1);
+  SDLoc DL(SVN);
+  MVT VT = SVN->getSimpleValueType(0);
+  unsigned NumElts = VT.getVectorNumElements();
+  ArrayRef<int> Mask = SVN->getMask();
+
+  if ((VT != MVT::v8i8 && VT != MVT::v4i16) ||
+      V1.getSimpleValueType() != VT || V2.getSimpleValueType() != VT)
+    return SDValue();
+
+  SmallVector<unsigned, 2> StartIndexes;
+  if (!V2.isUndef() &&
+      ShuffleVectorInst::isInterleaveMask(Mask, 2, NumElts * 2,
+                                          StartIndexes)) {
+    int EvenSrc = StartIndexes[0];
----------------
topperc wrote:

StartIndexes is `unsigned`, why is `EvenSrc` `int`?

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


More information about the llvm-commits mailing list