Skip to content

Commit 6984ba7

Browse files
committed
[InstSimply] Add tests for simplify (fmul -x, +/-0); NFC
1 parent ff63d62 commit 6984ba7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,53 @@ define double @fmul_nnan_ninf_nneg_n0.0_commute(i127 %x) {
211211
ret double %r
212212
}
213213

214+
define float @src_mul_nzero_neg(float nofpclass(inf nan pzero psub pnorm) %f) {
215+
; CHECK-LABEL: @src_mul_nzero_neg(
216+
; CHECK-NEXT: [[R:%.*]] = fmul float [[F:%.*]], -0.000000e+00
217+
; CHECK-NEXT: ret float [[R]]
218+
;
219+
%r = fmul float %f, -0.0
220+
ret float %r
221+
}
222+
223+
define <2 x float> @src_mul_zero_neg(<2 x float> nofpclass(inf nan pzero psub pnorm) %f) {
224+
; CHECK-LABEL: @src_mul_zero_neg(
225+
; CHECK-NEXT: [[R:%.*]] = fmul <2 x float> zeroinitializer, [[F:%.*]]
226+
; CHECK-NEXT: ret <2 x float> [[R]]
227+
;
228+
%r = fmul <2 x float> <float 0.0, float 0.0>, %f
229+
ret <2 x float> %r
230+
}
231+
232+
define <2 x float> @src_mul_zero_and_nzero_neg(<2 x float> nofpclass(inf nan pzero psub pnorm) %f) {
233+
; CHECK-LABEL: @src_mul_zero_and_nzero_neg(
234+
; CHECK-NEXT: [[R:%.*]] = fmul <2 x float> <float -0.000000e+00, float 0.000000e+00>, [[F:%.*]]
235+
; CHECK-NEXT: ret <2 x float> [[R]]
236+
;
237+
%r = fmul <2 x float> <float -0.0, float 0.0>, %f
238+
ret <2 x float> %r
239+
}
240+
241+
242+
define float @src_muladd_zero_neg(float nofpclass(inf nan pzero psub pnorm) %f, float %add) {
243+
; CHECK-LABEL: @src_muladd_zero_neg(
244+
; CHECK-NEXT: [[R:%.*]] = call float @llvm.fmuladd.f32(float [[F:%.*]], float 0.000000e+00, float [[ADD:%.*]])
245+
; CHECK-NEXT: ret float [[R]]
246+
;
247+
%r = call float @llvm.fmuladd.f32(float %f, float 0.0, float %add)
248+
ret float %r
249+
}
250+
251+
define float @src_fma_nzero_neg(float nofpclass(inf nan pzero psub pnorm) %f, float %add) {
252+
; CHECK-LABEL: @src_fma_nzero_neg(
253+
; CHECK-NEXT: [[R:%.*]] = call float @llvm.fma.f32(float -0.000000e+00, float [[F:%.*]], float [[ADD:%.*]])
254+
; CHECK-NEXT: ret float [[R]]
255+
;
256+
%r = call float @llvm.fma.f32(float -0.0, float %f, float %add)
257+
ret float %r
258+
}
259+
260+
214261
; Make sure we can infer %x can't be 0 based on assumes.
215262
define { float, float } @test_fmul_0_assumed_finite(float %x) {
216263
; CHECK-LABEL: @test_fmul_0_assumed_finite(

0 commit comments

Comments
 (0)