diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -13113,6 +13113,8 @@ return Builder.CreateBitCast(Sext, FPVecTy); }; + IRBuilder<>::FastMathFlagGuard FMFGuard(Builder); + switch (BuiltinID) { default: return nullptr; case X86::BI_mm_prefetch: { diff --git a/clang/test/CodeGen/builtins-x86-reduce.c b/clang/test/CodeGen/builtins-x86-reduce.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/builtins-x86-reduce.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -target-feature +avx512f -emit-llvm -o - | FileCheck %s + +typedef double double8 __attribute__((ext_vector_type(8))); + +double foo(double8 a, double b) { + return __builtin_ia32_reduce_fmax_pd512(a) + b; +} + +// CHECK: fadd +// CHECK-NOT: nnan +// CHECK-SAME: double