Index: llvm/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/lib/Analysis/InstructionSimplify.cpp +++ llvm/lib/Analysis/InstructionSimplify.cpp @@ -5444,6 +5444,10 @@ if (match(Op0, m_FNegNSZ(m_Specific(Op1))) || match(Op1, m_FNegNSZ(m_Specific(Op0)))) return ConstantFP::get(Op0->getType(), -1.0); + + // nnan ninf X / 0.0 -> poison + if (FMF.noInfs() && match(Op1, m_AnyZeroFP())) + return PoisonValue::get(Op1->getType()); } return nullptr; Index: llvm/test/Transforms/InstSimplify/fdiv.ll =================================================================== --- llvm/test/Transforms/InstSimplify/fdiv.ll +++ llvm/test/Transforms/InstSimplify/fdiv.ll @@ -64,8 +64,7 @@ ; https://alive2.llvm.org/ce/z/ryZBn6 define float @fdiv_nnan_ninf_by_zero_f32(float %x) { ; CHECK-LABEL: @fdiv_nnan_ninf_by_zero_f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan ninf float [[X:%.*]], 0.000000e+00 -; CHECK-NEXT: ret float [[FDIV]] +; CHECK-NEXT: ret float poison ; %fdiv = fdiv nnan ninf float %x, 0.0 ret float %fdiv @@ -73,8 +72,7 @@ define float @fdiv_nnan_ninf_by_negzero_f32(float %x) { ; CHECK-LABEL: @fdiv_nnan_ninf_by_negzero_f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan ninf float [[X:%.*]], -0.000000e+00 -; CHECK-NEXT: ret float [[FDIV]] +; CHECK-NEXT: ret float poison ; %fdiv = fdiv nnan ninf float %x, -0.0 ret float %fdiv @@ -98,8 +96,7 @@ define <2 x float> @fdiv_nnan_ninf_by_zero_v2f32(<2 x float> %x) { ; CHECK-LABEL: @fdiv_nnan_ninf_by_zero_v2f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan ninf <2 x float> [[X:%.*]], zeroinitializer -; CHECK-NEXT: ret <2 x float> [[FDIV]] +; CHECK-NEXT: ret <2 x float> poison ; %fdiv = fdiv nnan ninf <2 x float> %x, zeroinitializer ret <2 x float> %fdiv @@ -115,8 +112,7 @@ define <2 x float> @fdiv_nnan_ninf_by_zero_undef_v2f32(<2 x float> %x) { ; CHECK-LABEL: @fdiv_nnan_ninf_by_zero_undef_v2f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan ninf <2 x float> [[X:%.*]], -; CHECK-NEXT: ret <2 x float> [[FDIV]] +; CHECK-NEXT: ret <2 x float> poison ; %fdiv = fdiv nnan ninf <2 x float> %x, ret <2 x float> %fdiv