Index: llvm/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/lib/Analysis/InstructionSimplify.cpp +++ llvm/lib/Analysis/InstructionSimplify.cpp @@ -5448,6 +5448,10 @@ // nnan ninf X / 0.0 -> poison if (FMF.noInfs() && match(Op1, m_AnyZeroFP())) return PoisonValue::get(Op1->getType()); + + // nnan nsz X / 0.0 -> inf + if (FMF.noSignedZeros() && match(Op1, m_AnyZeroFP())) + return ConstantFP::getInfinity(Op1->getType()); } return nullptr; Index: llvm/test/Transforms/InstSimplify/fdiv.ll =================================================================== --- llvm/test/Transforms/InstSimplify/fdiv.ll +++ llvm/test/Transforms/InstSimplify/fdiv.ll @@ -121,8 +121,7 @@ ; https://alive2.llvm.org/ce/z/ryZBn6 define float @fdiv_nnan_nsz_ninf_by_zero_f32(float %x) { ; CHECK-LABEL: @fdiv_nnan_nsz_ninf_by_zero_f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan nsz float [[X:%.*]], 0.000000e+00 -; CHECK-NEXT: ret float [[FDIV]] +; CHECK-NEXT: ret float 0x7FF0000000000000 ; %fdiv = fdiv nnan nsz float %x, 0.0 ret float %fdiv @@ -130,8 +129,7 @@ define float @fdiv_nnan_nsz_ninf_by_negzero_f32(float %x) { ; CHECK-LABEL: @fdiv_nnan_nsz_ninf_by_negzero_f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan nsz float [[X:%.*]], -0.000000e+00 -; CHECK-NEXT: ret float [[FDIV]] +; CHECK-NEXT: ret float 0x7FF0000000000000 ; %fdiv = fdiv nnan nsz float %x, -0.0 ret float %fdiv @@ -139,8 +137,7 @@ define <2 x float> @fdiv_nnan_nsz_ninf_by_zero_v2f32(<2 x float> %x) { ; CHECK-LABEL: @fdiv_nnan_nsz_ninf_by_zero_v2f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan nsz <2 x float> [[X:%.*]], zeroinitializer -; CHECK-NEXT: ret <2 x float> [[FDIV]] +; CHECK-NEXT: ret <2 x float> ; %fdiv = fdiv nnan nsz <2 x float> %x, zeroinitializer ret <2 x float> %fdiv @@ -148,8 +145,7 @@ define <2 x float> @fdiv_nnan_nsz_ninf_by_negzero_v2f32(<2 x float> %x) { ; CHECK-LABEL: @fdiv_nnan_nsz_ninf_by_negzero_v2f32( -; CHECK-NEXT: [[FDIV:%.*]] = fdiv nnan nsz <2 x float> [[X:%.*]], -; CHECK-NEXT: ret <2 x float> [[FDIV]] +; CHECK-NEXT: ret <2 x float> ; %fdiv = fdiv nnan nsz <2 x float> %x, ret <2 x float> %fdiv