aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2024-03-14 20:03:01 -0500
committerNoah Goldstein <goldstein.w.n@gmail.com>2024-03-18 15:11:55 -0500
commit6984ba7b94e13694caeea6a8dada9f79b2cc644a (patch)
tree79327c7d8950201f08ef98b84fed85fe02c36fea
parentff63d628c46459437df21e09f70993685eba4bc3 (diff)
downloadllvm-6984ba7b94e13694caeea6a8dada9f79b2cc644a.zip
llvm-6984ba7b94e13694caeea6a8dada9f79b2cc644a.tar.gz
llvm-6984ba7b94e13694caeea6a8dada9f79b2cc644a.tar.bz2
[InstSimply] Add tests for simplify `(fmul -x, +/-0)`; NFC
-rw-r--r--llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
index b8244b1..ffdca34 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-arithmetic.ll
@@ -211,6 +211,53 @@ define double @fmul_nnan_ninf_nneg_n0.0_commute(i127 %x) {
ret double %r
}
+define float @src_mul_nzero_neg(float nofpclass(inf nan pzero psub pnorm) %f) {
+; CHECK-LABEL: @src_mul_nzero_neg(
+; CHECK-NEXT: [[R:%.*]] = fmul float [[F:%.*]], -0.000000e+00
+; CHECK-NEXT: ret float [[R]]
+;
+ %r = fmul float %f, -0.0
+ ret float %r
+}
+
+define <2 x float> @src_mul_zero_neg(<2 x float> nofpclass(inf nan pzero psub pnorm) %f) {
+; CHECK-LABEL: @src_mul_zero_neg(
+; CHECK-NEXT: [[R:%.*]] = fmul <2 x float> zeroinitializer, [[F:%.*]]
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %r = fmul <2 x float> <float 0.0, float 0.0>, %f
+ ret <2 x float> %r
+}
+
+define <2 x float> @src_mul_zero_and_nzero_neg(<2 x float> nofpclass(inf nan pzero psub pnorm) %f) {
+; CHECK-LABEL: @src_mul_zero_and_nzero_neg(
+; CHECK-NEXT: [[R:%.*]] = fmul <2 x float> <float -0.000000e+00, float 0.000000e+00>, [[F:%.*]]
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %r = fmul <2 x float> <float -0.0, float 0.0>, %f
+ ret <2 x float> %r
+}
+
+
+define float @src_muladd_zero_neg(float nofpclass(inf nan pzero psub pnorm) %f, float %add) {
+; CHECK-LABEL: @src_muladd_zero_neg(
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.fmuladd.f32(float [[F:%.*]], float 0.000000e+00, float [[ADD:%.*]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %r = call float @llvm.fmuladd.f32(float %f, float 0.0, float %add)
+ ret float %r
+}
+
+define float @src_fma_nzero_neg(float nofpclass(inf nan pzero psub pnorm) %f, float %add) {
+; CHECK-LABEL: @src_fma_nzero_neg(
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.fma.f32(float -0.000000e+00, float [[F:%.*]], float [[ADD:%.*]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %r = call float @llvm.fma.f32(float -0.0, float %f, float %add)
+ ret float %r
+}
+
+
; Make sure we can infer %x can't be 0 based on assumes.
define { float, float } @test_fmul_0_assumed_finite(float %x) {
; CHECK-LABEL: @test_fmul_0_assumed_finite(