[clang] e6b3396 - [clang][bytecode] check reduce_min element type (#216536)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 16 02:32:14 PDT 2026
Author: Timm Baeder
Date: 2026-08-16T11:32:09+02:00
New Revision: e6b33964ac514f3f920b0c45d0c73b74a8ed2107
URL: https://github.com/llvm/llvm-project/commit/e6b33964ac514f3f920b0c45d0c73b74a8ed2107
DIFF: https://github.com/llvm/llvm-project/commit/e6b33964ac514f3f920b0c45d0c73b74a8ed2107.diff
LOG: [clang][bytecode] check reduce_min element type (#216536)
Only integer types are allowed.
Added:
Modified:
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/test/AST/ByteCode/builtin-functions.cpp
Removed:
################################################################################
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}}
+}
More information about the cfe-commits
mailing list