[llvm] c0f53ed - [InstCombine] add tests for fneg+fadd; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 22 05:59:46 PST 2020


Author: Sanjay Patel
Date: 2020-01-22T08:59:28-05:00
New Revision: c0f53ed80662fb9d5facbf0b05284f906a355c83

URL: https://github.com/llvm/llvm-project/commit/c0f53ed80662fb9d5facbf0b05284f906a355c83
DIFF: https://github.com/llvm/llvm-project/commit/c0f53ed80662fb9d5facbf0b05284f906a355c83.diff

LOG: [InstCombine] add tests for fneg+fadd; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/fneg.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/fneg.ll b/llvm/test/Transforms/InstCombine/fneg.ll
index bb701ba48953..fde55775f208 100644
--- a/llvm/test/Transforms/InstCombine/fneg.ll
+++ b/llvm/test/Transforms/InstCombine/fneg.ll
@@ -377,3 +377,103 @@ define float @fneg_fneg_sel_extra_use3(float %x, float %y, i1 %cond) {
   %sel = select i1 %cond, float %n1, float %n2
   ret float %sel
 }
+
+define float @fneg_fadd_constant(float %x) {
+; CHECK-LABEL: @fneg_fadd_constant(
+; CHECK-NEXT:    [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    [[R:%.*]] = fneg float [[A]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %a = fadd float %x, 42.0
+  %r = fneg float %a
+  ret float %r
+}
+
+define float @fake_nsz_fadd_constant(float %x) {
+; CHECK-LABEL: @fake_nsz_fadd_constant(
+; CHECK-NEXT:    [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    [[R:%.*]] = fsub float -0.000000e+00, [[A]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %a = fadd float %x, 42.0
+  %r = fsub float -0.0, %a
+  ret float %r
+}
+
+; TODO: -(X + C) --> -C - X
+
+define float @fneg_nsz_fadd_constant(float %x) {
+; CHECK-LABEL: @fneg_nsz_fadd_constant(
+; CHECK-NEXT:    [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    [[R:%.*]] = fneg nsz float [[A]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %a = fadd float %x, 42.0
+  %r = fneg nsz float %a
+  ret float %r
+}
+
+; TODO: -(X + C) --> -C - X
+
+define float @fake_fneg_nsz_fadd_constant(float %x) {
+; CHECK-LABEL: @fake_fneg_nsz_fadd_constant(
+; CHECK-NEXT:    [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    [[R:%.*]] = fsub fast float -0.000000e+00, [[A]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %a = fadd float %x, 42.0
+  %r = fsub fast float -0.0, %a
+  ret float %r
+}
+
+define float @fneg_nsz_fadd_constant_extra_use(float %x) {
+; CHECK-LABEL: @fneg_nsz_fadd_constant_extra_use(
+; CHECK-NEXT:    [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    call void @use(float [[A]])
+; CHECK-NEXT:    [[R:%.*]] = fneg nsz float [[A]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %a = fadd float %x, 42.0
+  call void @use(float %a)
+  %r = fneg nsz float %a
+  ret float %r
+}
+
+define float @fake_fneg_nsz_fadd_constant_extra_use(float %x) {
+; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_extra_use(
+; CHECK-NEXT:    [[A:%.*]] = fadd float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    call void @use(float [[A]])
+; CHECK-NEXT:    [[R:%.*]] = fsub fast float -0.000000e+00, [[A]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %a = fadd float %x, 42.0
+  call void @use(float %a)
+  %r = fsub fast float -0.0, %a
+  ret float %r
+}
+
+; TODO: -(X + C) --> -C - X
+
+define <2 x float> @fneg_nsz_fadd_constant_vec(<2 x float> %x) {
+; CHECK-LABEL: @fneg_nsz_fadd_constant_vec(
+; CHECK-NEXT:    [[A:%.*]] = fadd <2 x float> [[X:%.*]], <float 4.200000e+01, float 4.300000e+01>
+; CHECK-NEXT:    [[R:%.*]] = fneg reassoc nnan nsz <2 x float> [[A]]
+; CHECK-NEXT:    ret <2 x float> [[R]]
+;
+  %a = fadd <2 x float> %x, <float 42.0, float 43.0>
+  %r = fneg nsz nnan reassoc <2 x float> %a
+  ret <2 x float> %r
+}
+
+; TODO: -(X + C) --> -C - X
+
+define <2 x float> @fake_fneg_nsz_fadd_constant_vec(<2 x float> %x) {
+; CHECK-LABEL: @fake_fneg_nsz_fadd_constant_vec(
+; CHECK-NEXT:    [[A:%.*]] = fadd <2 x float> [[X:%.*]], <float 4.200000e+01, float undef>
+; CHECK-NEXT:    [[R:%.*]] = fsub nsz <2 x float> <float undef, float -0.000000e+00>, [[A]]
+; CHECK-NEXT:    ret <2 x float> [[R]]
+;
+  %a = fadd <2 x float> %x, <float 42.0, float undef>
+  %r = fsub nsz <2 x float> <float undef, float -0.0>, %a
+  ret <2 x float> %r
+}


        


More information about the llvm-commits mailing list