[llvm] r339203 - [InstCombine] add tests for fneg fold including FMF; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 7 16:24:25 PDT 2018


Author: spatel
Date: Tue Aug  7 16:24:25 2018
New Revision: 339203

URL: http://llvm.org/viewvc/llvm-project?rev=339203&view=rev
Log:
[InstCombine] add tests for fneg fold including FMF; NFC

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

Modified: llvm/trunk/test/Transforms/InstCombine/fneg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fneg.ll?rev=339203&r1=339202&r2=339203&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fneg.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fneg.ll Tue Aug  7 16:24:25 2018
@@ -16,7 +16,20 @@ define float @fmul_fneg(float %x) {
   ret float %r
 }
 
-; Extra use is ok.
+; Fast math is not required, but it should be propagated.
+
+define float @fmul_fneg_fmf(float %x) {
+; CHECK-LABEL: @fmul_fneg_fmf(
+; CHECK-NEXT:    [[M:%.*]] = fmul float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT:    [[R:%.*]] = fsub reassoc nsz float -0.000000e+00, [[M]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %m = fmul float %x, 42.0
+  %r = fsub reassoc nsz float -0.0, %m
+  ret float %r
+}
+
+; Extra use prevents the fold. We don't want to replace the fneg with an fmul.
 
 define float @fmul_fneg_extra_use(float %x) {
 ; CHECK-LABEL: @fmul_fneg_extra_use(
@@ -57,7 +70,20 @@ define float @fdiv_op1_constant_fneg(flo
   ret float %r
 }
 
-; Extra use is ok.
+; Fast math is not required, but it should be propagated.
+
+define float @fdiv_op1_constant_fneg_fmf(float %x) {
+; CHECK-LABEL: @fdiv_op1_constant_fneg_fmf(
+; CHECK-NEXT:    [[D:%.*]] = fdiv float [[X:%.*]], -4.200000e+01
+; CHECK-NEXT:    [[R:%.*]] = fsub nnan float -0.000000e+00, [[D]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %d = fdiv float %x, -42.0
+  %r = fsub nnan float -0.0, %d
+  ret float %r
+}
+
+; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
 
 define float @fdiv_op1_constant_fneg_extra_use(float %x) {
 ; CHECK-LABEL: @fdiv_op1_constant_fneg_extra_use(
@@ -98,7 +124,20 @@ define float @fdiv_op0_constant_fneg(flo
   ret float %r
 }
 
-; Extra use is ok.
+; Fast math is not required, but it should be propagated.
+
+define float @fdiv_op0_constant_fneg_fmf(float %x) {
+; CHECK-LABEL: @fdiv_op0_constant_fneg_fmf(
+; CHECK-NEXT:    [[D:%.*]] = fdiv float 4.200000e+01, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = fsub fast float -0.000000e+00, [[D]]
+; CHECK-NEXT:    ret float [[R]]
+;
+  %d = fdiv float 42.0, %x
+  %r = fsub fast float -0.0, %d
+  ret float %r
+}
+
+; Extra use prevents the fold. We don't want to replace the fneg with an fdiv.
 
 define float @fdiv_op0_constant_fneg_extra_use(float %x) {
 ; CHECK-LABEL: @fdiv_op0_constant_fneg_extra_use(




More information about the llvm-commits mailing list