[clang] [clang][bytecode] check reduce_min element type (PR #216536)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 15 23:19:54 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
Only integer types are allowed.
---
Full diff: https://github.com/llvm/llvm-project/pull/216536.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+3)
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+5)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 68fab67ebe848..a61451f22631d 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1711,6 +1711,9 @@ static bool interp__builtin_vector_reduce(InterpState &S, CodePtr OpPC,
PrimType ElemT = *S.getContext().classify(ElemType);
unsigned NumElems = Arg.getNumElems();
+ if (!isIntegerType(ElemT))
+ return false;
+
INT_TYPE_SWITCH_NO_BOOL(ElemT, {
T Result = Arg.elem<T>(0);
unsigned BitWidth = Result.bitWidth();
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp
index b14ae91c753cb..87ffb1cc5b609 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -2122,3 +2122,8 @@ namespace SubCb {
}
static_assert(subcb2() == 0);
}
+
+namespace ReduceMin {
+ typedef float v4f __attribute__((__vector_size__(16)));
+ static_assert(__builtin_reduce_min((v4f){1.123, 2.123, 3.123, 4.123}) == 0); // both-error {{not an integral constant expression}}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/216536
More information about the cfe-commits
mailing list