[clang] [Clang] Add float type support to __builtin_reduce_add and __builtin_reduce_multipy (PR #120367)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 3 09:15:17 PST 2025


================
@@ -1754,6 +1755,17 @@ static bool interp__builtin_vector_reduce(InterpState &S, CodePtr OpPC,
   PrimType ElemT = *S.getContext().classify(ElemType);
   unsigned NumElems = Arg.getNumElems();
 
+  if (ElemType->isRealFloatingType()) {
+    if (ID != Builtin::BI__builtin_reduce_add &&
+        ID != Builtin::BI__builtin_reduce_mul)
+      llvm_unreachable("Only reduce_add and reduce_mul are supported for "
----------------
farzonl wrote:

@llvm-beanz I don't understand how this code could be removed by the compiler. the Code after an unreachable is in a different block. The unreachable is gated by the builtin check.

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


More information about the cfe-commits mailing list