Index: include/llvm/CodeGen/SelectionDAGNodes.h =================================================================== --- include/llvm/CodeGen/SelectionDAGNodes.h +++ include/llvm/CodeGen/SelectionDAGNodes.h @@ -380,13 +380,21 @@ /// Propagate the fast-math-flags from an IR FPMathOperator. void copyFMF(const FPMathOperator &FPMO) { - setNoNaNs(FPMO.hasNoNaNs()); - setNoInfs(FPMO.hasNoInfs()); - setNoSignedZeros(FPMO.hasNoSignedZeros()); - setAllowReciprocal(FPMO.hasAllowReciprocal()); - setAllowContract(FPMO.hasAllowContract()); - setApproximateFuncs(FPMO.hasApproxFunc()); - setAllowReassociation(FPMO.hasAllowReassoc()); + // Allow for AnyDefined to be false if no flags are set + if (FPMO.hasNoNaNs()) + setNoNaNs(true); + if (FPMO.hasNoInfs()) + setNoInfs(true); + if (FPMO.hasNoSignedZeros()) + setNoSignedZeros(true); + if (FPMO.hasAllowReciprocal()) + setAllowReciprocal(true); + if (FPMO.hasAllowContract()) + setAllowContract(true); + if (FPMO.hasApproxFunc()) + setApproximateFuncs(true); + if (FPMO.hasAllowReassoc()) + setAllowReassociation(true); } /// Sets the state of the flags to the defined state. Index: test/CodeGen/X86/intersect-fma-fmf.ll =================================================================== --- test/CodeGen/X86/intersect-fma-fmf.ll +++ test/CodeGen/X86/intersect-fma-fmf.ll @@ -0,0 +1,21 @@ +; RUN: llc -mtriple=i686-unknown-unknown -mattr=+avx512f < %s | FileCheck %s + +define float @test_x86_fma_intersection_fmf(float %b) { +; CHECK-LABEL: test_x86_fma_intersection_fmf: +; CHECK: # %bb.0: +; CHECK: vfmadd213ss %xmm0, %xmm0, %xmm1 +; CHECK: retl + %tmp0 = alloca [4 x float], align 16 + %tmp1 = getelementptr [4 x float], [4 x float]* %tmp0, i64 0, i64 0 + %tmp2 = load float, float* %tmp1, align 4 + %tmp3 = fadd fast float %tmp2, %tmp2 + %tmp4 = fptosi float %tmp3 to i32 + %tmp5 = insertelement <4 x i32> undef, i32 %tmp4, i32 1 + %tmp6 = extractelement <4 x i32> %tmp5, i32 1 + %tmp7 = uitofp i32 %tmp6 to float + %tmp8 = fmul fast float %tmp7, %b + %tmp9 = fadd fast float %tmp8, %b + %tmp10 = insertelement <4 x float> undef, float %tmp9, i32 1 + %tmp11 = extractelement <4 x float> %tmp10, i32 1 + ret float %tmp11 +}