https://github.com/tbaederr updated 
https://github.com/llvm/llvm-project/pull/170217

>From 59b01f66e63062919dfde3e318dbeb8d11e8ef7d Mon Sep 17 00:00:00 2001
From: Adam <[email protected]>
Date: Mon, 1 Dec 2025 17:14:00 -0500
Subject: [PATCH 1/4] Replace interp__builtin_blend with
 interp__builtin_ia32_shuffle_generic implementation

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 971fce541bb88..bbd07759883e1 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -4624,7 +4624,15 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, 
const CallExpr *Call,
   case clang::X86::BI__builtin_ia32_pblendw256:
   case clang::X86::BI__builtin_ia32_pblendd128:
   case clang::X86::BI__builtin_ia32_pblendd256:
-    return interp__builtin_blend(S, OpPC, Call);
+    return interp__builtin_ia32_shuffle_generic(
+      S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
+        // bit index for mask
+        unsigned maskBit = (ShuffleMask >> (DstIdx % 8)) & 0x1;
+        unsigned SrcVecIdx = maskBit ? 1 : 0;  // 1 = TrueVec, 0 = FalseVec
+        return std::pair<unsigned, int>{SrcVecIdx, static_cast<int>(DstIdx)};
+      });
+
+
 
   case clang::X86::BI__builtin_ia32_blendvpd:
   case clang::X86::BI__builtin_ia32_blendvpd256:

>From f66695b33cf464886f24c2eebc44444e95507d38 Mon Sep 17 00:00:00 2001
From: adbox53 <[email protected]>
Date: Tue, 2 Dec 2025 09:06:36 -0500
Subject: [PATCH 2/4] Update clang/lib/AST/ByteCode/InterpBuiltin.cpp

Co-authored-by: Timm Baeder <[email protected]>
---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 3cc0f53ece86e..0123401eb47c9 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -4626,8 +4626,8 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
CallExpr *Call,
   case clang::X86::BI__builtin_ia32_pblendd256:
     return interp__builtin_ia32_shuffle_generic(
       S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
-        // bit index for mask
-        unsigned maskBit = (ShuffleMask >> (DstIdx % 8)) & 0x1;
+        // Bit index for mask.
+        unsigned MaskBit = (ShuffleMask >> (DstIdx % 8)) & 0x1;
         unsigned SrcVecIdx = maskBit ? 1 : 0;  // 1 = TrueVec, 0 = FalseVec
         return std::pair<unsigned, int>{SrcVecIdx, static_cast<int>(DstIdx)};
       });

>From de447f37ad967b38d758c95d8edeb1bae5ea6905 Mon Sep 17 00:00:00 2001
From: adbox53 <[email protected]>
Date: Tue, 2 Dec 2025 09:08:37 -0500
Subject: [PATCH 3/4] Update InterpBuiltin.cpp MaskBit variable

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 0123401eb47c9..db2307e4c7caa 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -4628,7 +4628,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
CallExpr *Call,
       S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
         // Bit index for mask.
         unsigned MaskBit = (ShuffleMask >> (DstIdx % 8)) & 0x1;
-        unsigned SrcVecIdx = maskBit ? 1 : 0;  // 1 = TrueVec, 0 = FalseVec
+        unsigned SrcVecIdx = MaskBit ? 1 : 0;  // 1 = TrueVec, 0 = FalseVec
         return std::pair<unsigned, int>{SrcVecIdx, static_cast<int>(DstIdx)};
       });
 

>From dbf735238ea73ea03953a8833f8c03d4c1689aa4 Mon Sep 17 00:00:00 2001
From: adbox53 <[email protected]>
Date: Wed, 3 Dec 2025 09:19:44 -0500
Subject: [PATCH 4/4] removed interp__builtin_blend from InterpBuiltin.cpp

---
 clang/lib/AST/ByteCode/InterpBuiltin.cpp | 33 ------------------------
 1 file changed, 33 deletions(-)

diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 2d89e4b97b66b..5308779498b59 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2843,39 +2843,6 @@ static bool interp__builtin_select_scalar(InterpState &S,
   return true;
 }
 
-static bool interp__builtin_blend(InterpState &S, CodePtr OpPC,
-                                  const CallExpr *Call) {
-  APSInt Mask = popToAPSInt(S, Call->getArg(2));
-  const Pointer &TrueVec = S.Stk.pop<Pointer>();
-  const Pointer &FalseVec = S.Stk.pop<Pointer>();
-  const Pointer &Dst = S.Stk.peek<Pointer>();
-
-  assert(FalseVec.getNumElems() == TrueVec.getNumElems());
-  assert(FalseVec.getNumElems() == Dst.getNumElems());
-  unsigned NumElems = FalseVec.getNumElems();
-  PrimType ElemT = FalseVec.getFieldDesc()->getPrimType();
-  PrimType DstElemT = Dst.getFieldDesc()->getPrimType();
-
-  for (unsigned I = 0; I != NumElems; ++I) {
-    bool MaskBit = Mask[I % 8];
-    if (ElemT == PT_Float) {
-      assert(DstElemT == PT_Float);
-      Dst.elem<Floating>(I) =
-          MaskBit ? TrueVec.elem<Floating>(I) : FalseVec.elem<Floating>(I);
-    } else {
-      assert(DstElemT == ElemT);
-      INT_TYPE_SWITCH_NO_BOOL(DstElemT, {
-        Dst.elem<T>(I) =
-            static_cast<T>(MaskBit ? TrueVec.elem<T>(I).toAPSInt()
-                                   : FalseVec.elem<T>(I).toAPSInt());
-      });
-    }
-  }
-  Dst.initializeAllElements();
-
-  return true;
-}
-
 static bool interp__builtin_ia32_test_op(
     InterpState &S, CodePtr OpPC, const CallExpr *Call,
     llvm::function_ref<bool(const APInt &A, const APInt &B)> Fn) {

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

Reply via email to