Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -495,8 +495,8 @@ unsigned ConstrainedIntrinsicID) { llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E); if (CGF.Builder.getIsFPConstrained()) { - CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E); Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType()); return CGF.Builder.CreateConstrainedFPCall(F, { Src0 }); } else { Index: clang/test/CodeGen/fp-contract-fast-pragma.cpp =================================================================== --- clang/test/CodeGen/fp-contract-fast-pragma.cpp +++ clang/test/CodeGen/fp-contract-fast-pragma.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -O3 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fexperimental-strict-floating-point -O3 \ +// RUN: -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s // Is FP_CONTRACT honored in a simple case? float fp_contract_1(float a, float b, float c) { @@ -67,3 +69,18 @@ // CHECK-NEXT: fadd float %[[M]], %c return a * b + c; } + + +#pragma clang fp contract(fast) +float fp_contract_7(float a) { +// CHECK: _Z13fp_contract_7f +// CHECK: tail call contract float @llvm.sqrt.f32(float %a) + return __builtin_sqrtf(a); +} + +float fp_contract_8(float a) { +// CHECK: _Z13fp_contract_8f +// CHECK: tail call float @llvm.sqrt.f32(float %a) +#pragma clang fp contract(off) + return __builtin_sqrtf(a); +}