Index: lib/Analysis/InstructionSimplify.cpp =================================================================== --- lib/Analysis/InstructionSimplify.cpp +++ lib/Analysis/InstructionSimplify.cpp @@ -791,7 +791,7 @@ if (Constant *CRHS = dyn_cast(Op1)) { Constant *Ops[] = { CLHS, CRHS }; return ConstantFoldInstOperands(Instruction::FAdd, CLHS->getType(), - Ops, Q.DL, Q.TLI); + Ops, Q.DL, Q.TLI, FMF); } // Canonicalize the constant to the RHS. @@ -833,7 +833,7 @@ if (Constant *CRHS = dyn_cast(Op1)) { Constant *Ops[] = { CLHS, CRHS }; return ConstantFoldInstOperands(Instruction::FSub, CLHS->getType(), - Ops, Q.DL, Q.TLI); + Ops, Q.DL, Q.TLI, FMF); } } @@ -871,7 +871,7 @@ if (Constant *CRHS = dyn_cast(Op1)) { Constant *Ops[] = { CLHS, CRHS }; return ConstantFoldInstOperands(Instruction::FMul, CLHS->getType(), - Ops, Q.DL, Q.TLI); + Ops, Q.DL, Q.TLI, FMF); } // Canonicalize the constant to the RHS. Index: test/Transforms/InstSimplify/fast-math.ll =================================================================== --- test/Transforms/InstSimplify/fast-math.ll +++ test/Transforms/InstSimplify/fast-math.ll @@ -171,3 +171,51 @@ ; CHECK-LABEL: fdiv_neg_swapped2 ; CHECK: ret float -1.000000e+00 } + +; CHECK-LABEL: @nofold_fadd_kexc( +define double @nofold_fadd_kexc() { +; CHECK: fadd +entry: + %val = fadd kexc double 1.000000e+308, 1.000000e+308 + ret double %val +} + +; CHECK-LABEL: @nofold_fsub_kexc( +define double @nofold_fsub_kexc() { +; CHECK: fsub +entry: + %val = fsub kexc double 1.000000e-308, 1.000000e+308 + ret double %val +} + +; CHECK-LABEL: @nofold_fmul_kexc( +define double @nofold_fmul_kexc() { +; CHECK: fmul +entry: + %val = fmul kexc double 1.000000e+300, 1.000000e+300 + ret double %val +} + +; CHECK-LABEL: @nofold_fadd_kround( +define double @nofold_fadd_kround() { +; CHECK: fadd +entry: + %val = fadd kround double 1.000000e+308, 1.000000e+308 + ret double %val +} + +; CHECK-LABEL: @nofold_fsub_kround( +define double @nofold_fsub_kround() { +; CHECK: fsub +entry: + %val = fsub kround double 1.000000e-308, 1.000000e+308 + ret double %val +} + +; CHECK-LABEL: @nofold_fmul_kround( +define double @nofold_fmul_kround() { +; CHECK: fmul +entry: + %val = fmul kround double 1.000000e+300, 1.000000e+300 + ret double %val +}