Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -4818,7 +4818,7 @@ case ISD::FMUL: case ISD::FDIV: case ISD::FREM: - if (getTarget().Options.UnsafeFPMath) + if (getTarget().Options.UnsafeFPMath || Flags.isFast()) return N2; break; case ISD::MUL: Index: test/CodeGen/X86/fp-undef.ll =================================================================== --- test/CodeGen/X86/fp-undef.ll +++ test/CodeGen/X86/fp-undef.ll @@ -14,7 +14,7 @@ ; UNSAFE-LABEL: fadd_undef_op0: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = fadd float undef, %x + %r = fadd fast float undef, %x ret float %r } @@ -27,7 +27,7 @@ ; UNSAFE-LABEL: fadd_undef_op1: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = fadd float %x, undef + %r = fadd fast float %x, undef ret float %r } @@ -35,7 +35,7 @@ ; ANY-LABEL: fsub_undef_op0: ; ANY: # %bb.0: ; ANY-NEXT: retq - %r = fsub float undef, %x + %r = fsub fast float undef, %x ret float %r } @@ -48,7 +48,7 @@ ; UNSAFE-LABEL: fsub_undef_op1: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = fsub float %x, undef + %r = fsub fast float %x, undef ret float %r } @@ -61,7 +61,7 @@ ; UNSAFE-LABEL: fmul_undef_op0: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = fmul float undef, %x + %r = fmul fast float undef, %x ret float %r } @@ -74,7 +74,7 @@ ; UNSAFE-LABEL: fmul_undef_op1: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = fmul float %x, undef + %r = fmul fast float %x, undef ret float %r } @@ -82,7 +82,7 @@ ; ANY-LABEL: fdiv_undef_op0: ; ANY: # %bb.0: ; ANY-NEXT: retq - %r = fdiv float undef, %x + %r = fdiv fast float undef, %x ret float %r } @@ -95,7 +95,7 @@ ; UNSAFE-LABEL: fdiv_undef_op1: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = fdiv float %x, undef + %r = fdiv fast float %x, undef ret float %r } @@ -103,7 +103,7 @@ ; ANY-LABEL: frem_undef_op0: ; ANY: # %bb.0: ; ANY-NEXT: retq - %r = frem float undef, %x + %r = frem fast float undef, %x ret float %r } @@ -115,7 +115,7 @@ ; UNSAFE-LABEL: frem_undef_op1: ; UNSAFE: # %bb.0: ; UNSAFE-NEXT: retq - %r = frem float %x, undef + %r = frem fast float %x, undef ret float %r } @@ -424,7 +424,6 @@ define double @fadd_undef_op1_fast_constant_nan(double %x) { ; STRICT-LABEL: fadd_undef_op1_fast_constant_nan: ; STRICT: # %bb.0: -; STRICT-NEXT: addsd {{.*}}(%rip), %xmm0 ; STRICT-NEXT: retq ; ; UNSAFE-LABEL: fadd_undef_op1_fast_constant_nan: @@ -472,7 +471,6 @@ define double @fmul_undef_op1_fast_constant_nan(double %x) { ; STRICT-LABEL: fmul_undef_op1_fast_constant_nan: ; STRICT: # %bb.0: -; STRICT-NEXT: mulsd {{.*}}(%rip), %xmm0 ; STRICT-NEXT: retq ; ; UNSAFE-LABEL: fmul_undef_op1_fast_constant_nan: @@ -543,7 +541,6 @@ define double @fadd_undef_op1_fast_constant_inf(double %x) { ; STRICT-LABEL: fadd_undef_op1_fast_constant_inf: ; STRICT: # %bb.0: -; STRICT-NEXT: addsd {{.*}}(%rip), %xmm0 ; STRICT-NEXT: retq ; ; UNSAFE-LABEL: fadd_undef_op1_fast_constant_inf: @@ -591,7 +588,6 @@ define double @fmul_undef_op1_fast_constant_inf(double %x) { ; STRICT-LABEL: fmul_undef_op1_fast_constant_inf: ; STRICT: # %bb.0: -; STRICT-NEXT: mulsd {{.*}}(%rip), %xmm0 ; STRICT-NEXT: retq ; ; UNSAFE-LABEL: fmul_undef_op1_fast_constant_inf: