[llvm] [GlobalISel] Add support for interleave and deinterleave intrinsics to IRTranslator (PR #85199)

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 01:50:22 PDT 2024


================
@@ -2474,6 +2475,49 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
 
     return true;
   }
+
+  case Intrinsic::experimental_vector_interleave2: {
+    Value *Src0 = CI.getOperand(0);
+    Value *Src1 = CI.getOperand(1);
+
+    // Canonicalize fixed-width vector types to G_SHUFFLE_VECTOR
+    // (similar to SelectionDAG)
+    LLT OpType = getLLTForType(*Src0->getType(), MIRBuilder.getDataLayout());
+    if (!OpType.isFixedVector())
+      break;
+
+    Register Op0 = getOrCreateVReg(*Src0);
+    Register Op1 = getOrCreateVReg(*Src1);
+    Register Res = getOrCreateVReg(CI);
+
+    MIRBuilder.buildShuffleVector(
+        Res, Op0, Op1, createInterleaveMask(OpType.getNumElements(), 2));
+
+    return true;
----------------
madhur13490 wrote:

ideally, I would like to outline this code to a function and call based on the condition to be met. This would look a lot cleaner. 

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


More information about the llvm-commits mailing list