[llvm] r339361 - [InstCombine] add vector tests for fsub+fmul; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 9 10:40:27 PDT 2018


Author: spatel
Date: Thu Aug  9 10:40:27 2018
New Revision: 339361

URL: http://llvm.org/viewvc/llvm-project?rev=339361&view=rev
Log:
[InstCombine] add vector tests for fsub+fmul; NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/fast-math.ll

Modified: llvm/trunk/test/Transforms/InstCombine/fast-math.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fast-math.ll?rev=339361&r1=339360&r2=339361&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fast-math.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fast-math.ll Thu Aug  9 10:40:27 2018
@@ -438,36 +438,65 @@ define double @fail2(double %f1, double
   ret double %t3
 }
 
-; c1 * x - x => (c1 - 1.0) * x
-define float @fold13(float %x) {
-; CHECK-LABEL: @fold13(
-; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast float [[X:%.*]], 6.000000e+00
+; (X * C) - X --> X * (C - 1.0)
+
+define float @fsub_op0_fmul_const(float %x) {
+; CHECK-LABEL: @fsub_op0_fmul_const(
+; CHECK-NEXT:    [[TMP1:%.*]] = fmul reassoc nsz float [[X:%.*]], 6.000000e+00
 ; CHECK-NEXT:    ret float [[TMP1]]
 ;
-  %mul = fmul fast float %x, 7.000000e+00
-  %sub = fsub fast float %mul, %x
+  %mul = fmul float %x, 7.0
+  %sub = fsub reassoc nsz float %mul, %x
   ret float %sub
 }
 
-; Check again using the minimal subset of FMF.
-define float @fold13_reassoc_nsz(float %x) {
-; CHECK-LABEL: @fold13_reassoc_nsz(
-; CHECK-NEXT:    [[TMP1:%.*]] = fmul reassoc nsz float [[X:%.*]], 6.000000e+00
+; (X * C) - X --> X * (C - 1.0)
+
+define <2 x float> @fsub_op0_fmul_const_vec(<2 x float> %x) {
+; CHECK-LABEL: @fsub_op0_fmul_const_vec(
+; CHECK-NEXT:    [[MUL:%.*]] = fmul <2 x float> [[X:%.*]], <float 7.000000e+00, float -4.200000e+01>
+; CHECK-NEXT:    [[SUB:%.*]] = fsub reassoc nsz <2 x float> [[MUL]], [[X]]
+; CHECK-NEXT:    ret <2 x float> [[SUB]]
+;
+  %mul = fmul <2 x float> %x, <float 7.0, float -42.0>
+  %sub = fsub reassoc nsz <2 x float> %mul, %x
+  ret <2 x float> %sub
+}
+
+; X - (X * C) --> X * (1.0 - C)
+
+define float @fsub_op1_fmul_const(float %x) {
+; CHECK-LABEL: @fsub_op1_fmul_const(
+; CHECK-NEXT:    [[TMP1:%.*]] = fmul reassoc nsz float [[X:%.*]], -6.000000e+00
 ; CHECK-NEXT:    ret float [[TMP1]]
 ;
-  %mul = fmul reassoc nsz float %x, 7.000000e+00
-  %sub = fsub reassoc nsz float %mul, %x
+  %mul = fmul float %x, 7.0
+  %sub = fsub reassoc nsz float %x, %mul
   ret float %sub
 }
 
+; X - (X * C) --> X * (1.0 - C)
+
+define <2 x float> @fsub_op1_fmul_const_vec(<2 x float> %x) {
+; CHECK-LABEL: @fsub_op1_fmul_const_vec(
+; CHECK-NEXT:    [[MUL:%.*]] = fmul <2 x float> [[X:%.*]], <float 7.000000e+00, float 0.000000e+00>
+; CHECK-NEXT:    [[SUB:%.*]] = fsub reassoc nsz <2 x float> [[X]], [[MUL]]
+; CHECK-NEXT:    ret <2 x float> [[SUB]]
+;
+  %mul = fmul <2 x float> %x, <float 7.0, float 0.0>
+  %sub = fsub reassoc nsz <2 x float> %x, %mul
+  ret <2 x float> %sub
+}
+
 ; Verify the fold is not done with only 'reassoc' ('nsz' is required).
-define float @fold13_reassoc(float %x) {
-; CHECK-LABEL: @fold13_reassoc(
+
+define float @fsub_op0_fmul_const_wrong_FMF(float %x) {
+; CHECK-LABEL: @fsub_op0_fmul_const_wrong_FMF(
 ; CHECK-NEXT:    [[MUL:%.*]] = fmul reassoc float [[X:%.*]], 7.000000e+00
 ; CHECK-NEXT:    [[SUB:%.*]] = fsub reassoc float [[MUL]], [[X]]
 ; CHECK-NEXT:    ret float [[SUB]]
 ;
-  %mul = fmul reassoc float %x, 7.000000e+00
+  %mul = fmul reassoc float %x, 7.0
   %sub = fsub reassoc float %mul, %x
   ret float %sub
 }




More information about the llvm-commits mailing list