[llvm] r326528 - [InstCombine] Add more test case to fpextend.ll.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 17:34:42 PST 2018


Author: ctopper
Date: Thu Mar  1 17:34:42 2018
New Revision: 326528

URL: http://llvm.org/viewvc/llvm-project?rev=326528&view=rev
Log:
[InstCombine] Add more test case to fpextend.ll.

This includes the test cases from D43970 and additional tests for combining (fptrunc (binop (fpext), (fpext))) where the pre-extended types don't match the trunc and therefore can't be completely removed.

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

Modified: llvm/trunk/test/Transforms/InstCombine/fpextend.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fpextend.ll?rev=326528&r1=326527&r2=326528&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fpextend.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fpextend.ll Thu Mar  1 17:34:42 2018
@@ -86,3 +86,189 @@ entry:
   %tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
   ret <2 x float> %tmp34
 }
+
+define <2 x float> @not_half_shrinkable(<2 x float> %x) {
+; CHECK-LABEL: @not_half_shrinkable(
+; CHECK-NEXT:    [[EXT:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
+; CHECK-NEXT:    [[ADD:%.*]] = fadd <2 x double> [[EXT]], <double 0.000000e+00, double 2.049000e+03>
+; CHECK-NEXT:    [[R:%.*]] = fptrunc <2 x double> [[ADD]] to <2 x float>
+; CHECK-NEXT:    ret <2 x float> [[R]]
+;
+  %ext = fpext <2 x float> %x to <2 x double>
+  %add = fadd <2 x double> %ext, <double 0.0, double 2049.0>
+  %r = fptrunc <2 x double> %add to <2 x float>
+  ret <2 x float>  %r
+}
+
+define half @test7(float %a) nounwind {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT:    [[Y:%.*]] = fpext float [[A:%.*]] to double
+; CHECK-NEXT:    [[Z:%.*]] = fptrunc double [[Y]] to half
+; CHECK-NEXT:    ret half [[Z]]
+;
+  %y = fpext float %a to double
+  %z = fptrunc double %y to half
+  ret half %z
+}
+
+define float @test8(half %a) nounwind {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT:    [[Y:%.*]] = fpext half [[A:%.*]] to double
+; CHECK-NEXT:    [[Z:%.*]] = fptrunc double [[Y]] to float
+; CHECK-NEXT:    ret float [[Z]]
+;
+  %y = fpext half %a to double
+  %z = fptrunc double %y to float
+  ret float %z
+}
+
+define float @test9(half %x, half %y) nounwind  {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT:    [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
+; CHECK-NEXT:    [[TMP56:%.*]] = fmul float [[TMP0]], [[TMP1]]
+; CHECK-NEXT:    ret float [[TMP56]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp23 = fpext half %y to double
+  %tmp5 = fmul double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test10(half %x, float %y) nounwind  {
+; CHECK-LABEL: @test10(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT:    [[TMP56:%.*]] = fmul float [[TMP0]], [[Y:%.*]]
+; CHECK-NEXT:    ret float [[TMP56]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp23 = fpext float %y to double
+  %tmp5 = fmul double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test11(half %x) nounwind  {
+; CHECK-LABEL: @test11(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT:    [[TMP34:%.*]] = fadd float [[TMP0]], 0.000000e+00
+; CHECK-NEXT:    ret float [[TMP34]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp3 = fadd double %tmp1, 0.000000e+00
+  %tmp34 = fptrunc double %tmp3 to float
+  ret float %tmp34
+}
+
+define float @test12(float %x, half %y) nounwind  {
+; CHECK-LABEL: @test12(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[Y:%.*]] to float
+; CHECK-NEXT:    [[TMP34:%.*]] = fadd float [[TMP0]], [[X:%.*]]
+; CHECK-NEXT:    ret float [[TMP34]]
+;
+entry:
+  %tmp1 = fpext float %x to double
+  %tmp2 = fpext half %y to double
+  %tmp3 = fadd double %tmp1, %tmp2
+  %tmp34 = fptrunc double %tmp3 to float
+  ret float %tmp34
+}
+
+define float @test13(half %x, float %y) nounwind  {
+; CHECK-LABEL: @test13(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[TMP0]], [[Y:%.*]]
+; CHECK-NEXT:    ret float [[TMP56]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp23 = fpext float %y to double
+  %tmp5 = fdiv double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test14(float %x, half %y) nounwind  {
+; CHECK-LABEL: @test14(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[Y:%.*]] to float
+; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[X:%.*]], [[TMP0]]
+; CHECK-NEXT:    ret float [[TMP56]]
+;
+entry:
+  %tmp1 = fpext float %x to double
+  %tmp23 = fpext half %y to double
+  %tmp5 = fdiv double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test15(half %x, half %y) nounwind  {
+; CHECK-LABEL: @test15(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT:    [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
+; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[TMP0]], [[TMP1]]
+; CHECK-NEXT:    ret float [[TMP56]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp23 = fpext half %y to double
+  %tmp5 = fdiv double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test16(half %x, float %y) nounwind  {
+; CHECK-LABEL: @test16(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
+; CHECK-NEXT:    [[TMP1:%.*]] = frem float [[TMP0]], [[Y:%.*]]
+; CHECK-NEXT:    ret float [[TMP1]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp23 = fpext float %y to double
+  %tmp5 = frem double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test17(float %x, half %y) nounwind  {
+; CHECK-LABEL: @test17(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[Y:%.*]] to float
+; CHECK-NEXT:    [[TMP1:%.*]] = frem float [[X:%.*]], [[TMP0]]
+; CHECK-NEXT:    ret float [[TMP1]]
+;
+entry:
+  %tmp1 = fpext float %x to double
+  %tmp23 = fpext half %y to double
+  %tmp5 = frem double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}
+
+define float @test18(half %x, half %y) nounwind  {
+; CHECK-LABEL: @test18(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = frem half [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    [[TMP56:%.*]] = fpext half [[TMP0]] to float
+; CHECK-NEXT:    ret float [[TMP56]]
+;
+entry:
+  %tmp1 = fpext half %x to double
+  %tmp23 = fpext half %y to double
+  %tmp5 = frem double %tmp1, %tmp23
+  %tmp56 = fptrunc double %tmp5 to float
+  ret float %tmp56
+}




More information about the llvm-commits mailing list