================
@@ -2937,6 +2937,56 @@ static bool interp__builtin_elementwise_triop(
   return true;
 }
 
+static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC,
+                                                 const CallExpr *Call,
+                                                 unsigned ID) {
+  assert(Call->getNumArgs() == 3);
+
+  PrimType ImmPT = *S.getContext().classify(Call->getArg(2));
+  APSInt ImmAPS = popToAPSInt(S.Stk, ImmPT);
+  uint64_t Index = ImmAPS.getZExtValue();
+
+  const Pointer &SubVec = S.Stk.pop<Pointer>();
+  if (!SubVec.getFieldDesc()->isPrimitiveArray()) {
+    return Invalid(S, OpPC);
+  }
+
+  const Pointer &DstVec = S.Stk.pop<Pointer>();
+  if (!DstVec.getFieldDesc()->isPrimitiveArray()) {
+    return Invalid(S, OpPC);
+  }
+
+  const Pointer &Result = S.Stk.peek<Pointer>();
+
+  unsigned DstElements = DstVec.getNumElems();
+  unsigned SubElements = SubVec.getNumElems();
+
+  if (SubElements == 0 || DstElements == 0 || (DstElements % SubElements) != 0)
+    return Invalid(S, OpPC);
+
+  unsigned NumLanes = DstElements / SubElements;
+  unsigned Lane = static_cast<unsigned>(Index % NumLanes);
+
+  QualType ElemType = DstVec.getFieldDesc()->getElemQualType();
+  PrimType ElemPT = *S.getContext().classify(ElemType);
+
+  unsigned InsertPos = Lane * SubElements;
+
+  TYPE_SWITCH(ElemPT, {
+    for (unsigned i = 0; i < DstElements; ++i) {
----------------
tbaederr wrote:

```suggestion
    for (unsigned I = 0; i != DstElements; ++i) {
```

https://github.com/llvm/llvm-project/pull/158778
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to