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 @@ -14737,8 +14737,11 @@ case X86::BI__builtin_ia32_reduce_fadd_ph128: { Function *F = CGM.getIntrinsic(Intrinsic::vector_reduce_fadd, Ops[1]->getType()); + FastMathFlags FMF = Builder.getFastMathFlags(); Builder.getFastMathFlags().setAllowReassoc(); - return Builder.CreateCall(F, {Ops[0], Ops[1]}); + Value *FAdd = Builder.CreateCall(F, {Ops[0], Ops[1]}); + Builder.getFastMathFlags() &= (FMF); + return FAdd; } case X86::BI__builtin_ia32_reduce_fmul_pd512: case X86::BI__builtin_ia32_reduce_fmul_ps512: @@ -14747,8 +14750,11 @@ case X86::BI__builtin_ia32_reduce_fmul_ph128: { Function *F = CGM.getIntrinsic(Intrinsic::vector_reduce_fmul, Ops[1]->getType()); + FastMathFlags FMF = Builder.getFastMathFlags(); Builder.getFastMathFlags().setAllowReassoc(); - return Builder.CreateCall(F, {Ops[0], Ops[1]}); + Value *FMul = Builder.CreateCall(F, {Ops[0], Ops[1]}); + Builder.getFastMathFlags() &= (FMF); + return FMul; } case X86::BI__builtin_ia32_reduce_fmax_pd512: case X86::BI__builtin_ia32_reduce_fmax_ps512: @@ -14757,8 +14763,11 @@ case X86::BI__builtin_ia32_reduce_fmax_ph128: { Function *F = CGM.getIntrinsic(Intrinsic::vector_reduce_fmax, Ops[0]->getType()); + FastMathFlags FMF = Builder.getFastMathFlags(); Builder.getFastMathFlags().setNoNaNs(); - return Builder.CreateCall(F, {Ops[0]}); + Value *FMax = Builder.CreateCall(F, {Ops[0]}); + Builder.getFastMathFlags() &= (FMF); + return FMax; } case X86::BI__builtin_ia32_reduce_fmin_pd512: case X86::BI__builtin_ia32_reduce_fmin_ps512: @@ -14767,8 +14776,11 @@ case X86::BI__builtin_ia32_reduce_fmin_ph128: { Function *F = CGM.getIntrinsic(Intrinsic::vector_reduce_fmin, Ops[0]->getType()); + FastMathFlags FMF = Builder.getFastMathFlags(); Builder.getFastMathFlags().setNoNaNs(); - return Builder.CreateCall(F, {Ops[0]}); + Value *FMin = Builder.CreateCall(F, {Ops[0]}); + Builder.getFastMathFlags() &= (FMF); + return FMin; } // 3DNow!