[clang] [clang][bytecode] check reduce_min element type (PR #216536)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 15 23:13:39 PDT 2026
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/216536
Only integer types are allowed.
>From f7f3916d63de1bec6e24541f4686c1bb5a555b6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 16 Aug 2026 08:05:07 +0200
Subject: [PATCH] [clang][bytecode] check reduce_min element type
Only integer types are allowed.
---
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 3 +++
clang/test/AST/ByteCode/builtin-functions.cpp | 5 +++++
2 files changed, 8 insertions(+)
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