[clang] [clang][x86] Add constexpr support for VNNI intrinsics (PR #190549)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 09:26:30 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c,h -- clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/lib/AST/ExprConstant.cpp clang/lib/Headers/avx512vlvnniintrin.h clang/lib/Headers/avx512vnniintrin.h clang/lib/Headers/avxvnniintrin.h clang/test/CodeGen/X86/avx512vlvnni-builtins.c clang/test/CodeGen/X86/avx512vnni-builtins.c clang/test/CodeGen/X86/avxvnni-builtins.c --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 196a5170c..78570d7cf 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -4190,8 +4190,7 @@ static bool interp__builtin_ia32_gfni_mul(InterpState &S, CodePtr OpPC,
 }
 
 static bool interp__builtin_ia32_vpdp(InterpState &S, CodePtr OpPC,
-                                      const CallExpr *Call,
-                                      bool IsSaturating) {
+                                      const CallExpr *Call, bool IsSaturating) {
   const auto *SrcVecT = Call->getArg(0)->getType()->castAs<VectorType>();
   const auto *OpAVecT = Call->getArg(1)->getType()->castAs<VectorType>();
   const auto *OpBVecT = Call->getArg(2)->getType()->castAs<VectorType>();
@@ -6117,14 +6116,14 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
     case X86::BI__builtin_ia32_vpdpwssd128:
     case X86::BI__builtin_ia32_vpdpwssd256:
     case X86::BI__builtin_ia32_vpdpwssd512:
-	case X86::BI__builtin_ia32_vpdpbusd128:
+    case X86::BI__builtin_ia32_vpdpbusd128:
     case X86::BI__builtin_ia32_vpdpbusd256:
     case X86::BI__builtin_ia32_vpdpbusd512:
       return interp__builtin_ia32_vpdp(S, OpPC, Call, false);
     case X86::BI__builtin_ia32_vpdpwssds128:
     case X86::BI__builtin_ia32_vpdpwssds256:
     case X86::BI__builtin_ia32_vpdpwssds512:
-	case X86::BI__builtin_ia32_vpdpbusds128:
+    case X86::BI__builtin_ia32_vpdpbusds128:
     case X86::BI__builtin_ia32_vpdpbusds256:
     case X86::BI__builtin_ia32_vpdpbusds512:
       return interp__builtin_ia32_vpdp(S, OpPC, Call, true);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 989b68c2a..400fa93fb 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -14652,7 +14652,7 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
     case X86::BI__builtin_ia32_vpdpwssd128:
     case X86::BI__builtin_ia32_vpdpwssd256:
     case X86::BI__builtin_ia32_vpdpwssd512:
-	case X86::BI__builtin_ia32_vpdpbusd128:
+    case X86::BI__builtin_ia32_vpdpbusd128:
     case X86::BI__builtin_ia32_vpdpbusd256:
     case X86::BI__builtin_ia32_vpdpbusd512:
       IsSaturating = false;
@@ -14675,9 +14675,9 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
 
     unsigned NumSrcElts = Source.getVectorLength();
     unsigned NumOperandElts = OperandA.getVectorLength();
-	unsigned EltsPerLane = NumOperandElts / NumSrcElts;
+    unsigned EltsPerLane = NumOperandElts / NumSrcElts;
 
-	assert(OperandA.getVectorLength() == OperandB.getVectorLength());
+    assert(OperandA.getVectorLength() == OperandB.getVectorLength());
 
     SmallVector<APValue, 16> Result;
     Result.reserve(NumSrcElts);
@@ -14685,9 +14685,12 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
       APSInt DotProduct = Source.getVectorElt(I).getInt();
       DotProduct = DotProduct.extend(64);
       for (unsigned J = 0; J != EltsPerLane; ++J) {
-        APSInt OpA = APSInt(OperandA.getVectorElt(EltsPerLane * I + J).getInt().extend(64), false);
+        APSInt OpA = APSInt(
+            OperandA.getVectorElt(EltsPerLane * I + J).getInt().extend(64),
+            false);
         APSInt OpB = APSInt(
-            OperandB.getVectorElt(EltsPerLane * I + J).getInt().extend(64), false);
+            OperandB.getVectorElt(EltsPerLane * I + J).getInt().extend(64),
+            false);
         DotProduct += OpA * OpB;
       }
       if (IsSaturating) {

``````````

</details>


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


More information about the cfe-commits mailing list