[llvm] r349801 - [ConstantFolding] Split up saturating add/sub tests; NFC

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 20 11:46:30 PST 2018


Author: nikic
Date: Thu Dec 20 11:46:30 2018
New Revision: 349801

URL: http://llvm.org/viewvc/llvm-project?rev=349801&view=rev
Log:
[ConstantFolding] Split up saturating add/sub tests; NFC

Split each test into a separate function.

Modified:
    llvm/trunk/test/Analysis/ConstantFolding/saturating-add-sub.ll

Modified: llvm/trunk/test/Analysis/ConstantFolding/saturating-add-sub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ConstantFolding/saturating-add-sub.ll?rev=349801&r1=349800&r2=349801&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ConstantFolding/saturating-add-sub.ll (original)
+++ llvm/trunk/test/Analysis/ConstantFolding/saturating-add-sub.ll Thu Dec 20 11:46:30 2018
@@ -1,9 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -constprop -S | FileCheck %s
 
-declare void @dummy(i8)
-declare void @dummy_vec(<2 x i8>)
-
 declare i8 @llvm.uadd.sat.i8(i8, i8)
 declare i8 @llvm.sadd.sat.i8(i8, i8)
 declare <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8>, <2 x i8>)
@@ -14,98 +11,162 @@ declare i8 @llvm.ssub.sat.i8(i8, i8)
 declare <2 x i8> @llvm.usub.sat.v2i8(<2 x i8>, <2 x i8>)
 declare <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8>, <2 x i8>)
 
-define void @test_add_scalar() {
-; CHECK-LABEL: @test_add_scalar(
-; CHECK-NEXT:    call void @dummy(i8 30)
-; CHECK-NEXT:    call void @dummy(i8 -1)
-; CHECK-NEXT:    call void @dummy(i8 -10)
-; CHECK-NEXT:    call void @dummy(i8 127)
-; CHECK-NEXT:    call void @dummy(i8 -128)
-; CHECK-NEXT:    ret void
-;
-  %x1 = call i8 @llvm.uadd.sat.i8(i8 10, i8 20)
-  call void @dummy(i8 %x1)
-  %x2 = call i8 @llvm.uadd.sat.i8(i8 250, i8 100)
-  call void @dummy(i8 %x2)
-
-  %y1 = call i8 @llvm.sadd.sat.i8(i8 10, i8 -20)
-  call void @dummy(i8 %y1)
-  %y2 = call i8 @llvm.sadd.sat.i8(i8 120, i8 10)
-  call void @dummy(i8 %y2)
-  %y3 = call i8 @llvm.sadd.sat.i8(i8 -120, i8 -10)
-  call void @dummy(i8 %y3)
-
-  ret void
-}
-
-define void @test_add_vector(<2 x i8> %a) {
-; CHECK-LABEL: @test_add_vector(
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 20, i8 30>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 -1, i8 -1>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 -10, i8 -30>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 127, i8 127>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 -128, i8 -128>)
-; CHECK-NEXT:    ret void
-;
-  %x1 = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 15>, <2 x i8> <i8 10, i8 15>)
-  call void @dummy_vec(<2 x i8> %x1)
-  %x2 = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 100, i8 200>, <2 x i8> <i8 250, i8 100>)
-  call void @dummy_vec(<2 x i8> %x2)
-
-  %y1 = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 10, i8 -15>, <2 x i8> <i8 -20, i8 -15>)
-  call void @dummy_vec(<2 x i8> %y1)
-  %y2 = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 100, i8 10>, <2 x i8> <i8 30, i8 120>)
-  call void @dummy_vec(<2 x i8> %y2)
-  %y3 = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 -100, i8 -10>, <2 x i8> <i8 -30, i8 -120>)
-  call void @dummy_vec(<2 x i8> %y3)
-
-  ret void
-}
-
-define void @test_usub_ssub_scalar() {
-; CHECK-LABEL: @test_usub_ssub_scalar(
-; CHECK-NEXT:    call void @dummy(i8 10)
-; CHECK-NEXT:    call void @dummy(i8 0)
-; CHECK-NEXT:    call void @dummy(i8 -30)
-; CHECK-NEXT:    call void @dummy(i8 127)
-; CHECK-NEXT:    call void @dummy(i8 -128)
-; CHECK-NEXT:    ret void
-;
-  %x1 = call i8 @llvm.usub.sat.i8(i8 20, i8 10)
-  call void @dummy(i8 %x1)
-  %x2 = call i8 @llvm.usub.sat.i8(i8 200, i8 250)
-  call void @dummy(i8 %x2)
-
-  %y1 = call i8 @llvm.ssub.sat.i8(i8 -10, i8 20)
-  call void @dummy(i8 %y1)
-  %y2 = call i8 @llvm.ssub.sat.i8(i8 120, i8 -10)
-  call void @dummy(i8 %y2)
-  %y3 = call i8 @llvm.ssub.sat.i8(i8 -120, i8 10)
-  call void @dummy(i8 %y3)
-
-  ret void
-}
-
-define void @test_sub_vector(<2 x i8> %a) {
-; CHECK-LABEL: @test_sub_vector(
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 10, i8 5>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> zeroinitializer)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 30, i8 0>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 127, i8 127>)
-; CHECK-NEXT:    call void @dummy_vec(<2 x i8> <i8 -128, i8 -128>)
-; CHECK-NEXT:    ret void
-;
-  %x1 = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 20, i8 15>, <2 x i8> <i8 10, i8 10>)
-  call void @dummy_vec(<2 x i8> %x1)
-  %x2 = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 100, i8 200>, <2 x i8> <i8 150, i8 250>)
-  call void @dummy_vec(<2 x i8> %x2)
-
-  %y1 = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 10, i8 -15>, <2 x i8> <i8 -20, i8 -15>)
-  call void @dummy_vec(<2 x i8> %y1)
-  %y2 = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 100, i8 10>, <2 x i8> <i8 -30, i8 -120>)
-  call void @dummy_vec(<2 x i8> %y2)
-  %y3 = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 -100, i8 -10>, <2 x i8> <i8 30, i8 120>)
-  call void @dummy_vec(<2 x i8> %y3)
+define i8 @test_uadd_scalar_no_sat() {
+; CHECK-LABEL: @test_uadd_scalar_no_sat(
+; CHECK-NEXT:    ret i8 30
+;
+  %x = call i8 @llvm.uadd.sat.i8(i8 10, i8 20)
+  ret i8 %x
+}
+
+define i8 @test_uadd_scalar_sat() {
+; CHECK-LABEL: @test_uadd_scalar_sat(
+; CHECK-NEXT:    ret i8 -1
+;
+  %x = call i8 @llvm.uadd.sat.i8(i8 250, i8 100)
+  ret i8 %x
+}
+
+define i8 @test_sadd_scalar_no_sat() {
+; CHECK-LABEL: @test_sadd_scalar_no_sat(
+; CHECK-NEXT:    ret i8 -10
+;
+  %x = call i8 @llvm.sadd.sat.i8(i8 10, i8 -20)
+  ret i8 %x
+}
+
+define i8 @test_sadd_scalar_sat_pos() {
+; CHECK-LABEL: @test_sadd_scalar_sat_pos(
+; CHECK-NEXT:    ret i8 127
+;
+  %x = call i8 @llvm.sadd.sat.i8(i8 120, i8 10)
+  ret i8 %x
+}
+
+define i8 @test_sadd_scalar_sat_neg() {
+; CHECK-LABEL: @test_sadd_scalar_sat_neg(
+; CHECK-NEXT:    ret i8 -128
+;
+  %x = call i8 @llvm.sadd.sat.i8(i8 -120, i8 -10)
+  ret i8 %x
+}
+
+define <2 x i8> @test_uadd_vector_no_sat(<2 x i8> %a) {
+; CHECK-LABEL: @test_uadd_vector_no_sat(
+; CHECK-NEXT:    ret <2 x i8> <i8 20, i8 30>
+;
+  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 15>, <2 x i8> <i8 10, i8 15>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_uadd_vector_sat(<2 x i8> %a) {
+; CHECK-LABEL: @test_uadd_vector_sat(
+; CHECK-NEXT:    ret <2 x i8> <i8 -1, i8 -1>
+;
+  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 100, i8 200>, <2 x i8> <i8 250, i8 100>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_no_sat(<2 x i8> %a) {
+; CHECK-LABEL: @test_sadd_vector_no_sat(
+; CHECK-NEXT:    ret <2 x i8> <i8 -10, i8 -30>
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 10, i8 -15>, <2 x i8> <i8 -20, i8 -15>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_sat_pos(<2 x i8> %a) {
+; CHECK-LABEL: @test_sadd_vector_sat_pos(
+; CHECK-NEXT:    ret <2 x i8> <i8 127, i8 127>
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 100, i8 10>, <2 x i8> <i8 30, i8 120>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_sadd_vector_sat_neg(<2 x i8> %a) {
+; CHECK-LABEL: @test_sadd_vector_sat_neg(
+; CHECK-NEXT:    ret <2 x i8> <i8 -128, i8 -128>
+;
+  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 -100, i8 -10>, <2 x i8> <i8 -30, i8 -120>)
+  ret <2 x i8> %x
+}
+
+define i8 @test_usub_scalar_no_sat() {
+; CHECK-LABEL: @test_usub_scalar_no_sat(
+; CHECK-NEXT:    ret i8 10
+;
+  %x = call i8 @llvm.usub.sat.i8(i8 20, i8 10)
+  ret i8 %x
+}
+
+define i8 @test_usub_scalar_sat() {
+; CHECK-LABEL: @test_usub_scalar_sat(
+; CHECK-NEXT:    ret i8 0
+;
+  %x = call i8 @llvm.usub.sat.i8(i8 200, i8 250)
+  ret i8 %x
+}
 
-  ret void
+define i8 @test_ssub_scalar_no_sat() {
+; CHECK-LABEL: @test_ssub_scalar_no_sat(
+; CHECK-NEXT:    ret i8 -30
+;
+  %x = call i8 @llvm.ssub.sat.i8(i8 -10, i8 20)
+  ret i8 %x
+}
+
+define i8 @test_ssub_scalar_sat_pos() {
+; CHECK-LABEL: @test_ssub_scalar_sat_pos(
+; CHECK-NEXT:    ret i8 127
+;
+  %x = call i8 @llvm.ssub.sat.i8(i8 120, i8 -10)
+  ret i8 %x
+}
+
+define i8 @test_ssub_scalar_sat_neg() {
+; CHECK-LABEL: @test_ssub_scalar_sat_neg(
+; CHECK-NEXT:    ret i8 -128
+;
+  %x = call i8 @llvm.ssub.sat.i8(i8 -120, i8 10)
+  ret i8 %x
+}
+
+define <2 x i8> @test_usub_vector_no_sat(<2 x i8> %a) {
+; CHECK-LABEL: @test_usub_vector_no_sat(
+; CHECK-NEXT:    ret <2 x i8> <i8 10, i8 5>
+;
+  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 20, i8 15>, <2 x i8> <i8 10, i8 10>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_usub_vector_sat(<2 x i8> %a) {
+; CHECK-LABEL: @test_usub_vector_sat(
+; CHECK-NEXT:    ret <2 x i8> zeroinitializer
+;
+  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 100, i8 200>, <2 x i8> <i8 150, i8 250>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_no_sat(<2 x i8> %a) {
+; CHECK-LABEL: @test_ssub_vector_no_sat(
+; CHECK-NEXT:    ret <2 x i8> <i8 30, i8 0>
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 10, i8 -15>, <2 x i8> <i8 -20, i8 -15>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_sat_pos(<2 x i8> %a) {
+; CHECK-LABEL: @test_ssub_vector_sat_pos(
+; CHECK-NEXT:    ret <2 x i8> <i8 127, i8 127>
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 100, i8 10>, <2 x i8> <i8 -30, i8 -120>)
+  ret <2 x i8> %x
+}
+
+define <2 x i8> @test_ssub_vector_sat_neg(<2 x i8> %a) {
+; CHECK-LABEL: @test_ssub_vector_sat_neg(
+; CHECK-NEXT:    ret <2 x i8> <i8 -128, i8 -128>
+;
+  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 -100, i8 -10>, <2 x i8> <i8 30, i8 120>)
+  ret <2 x i8> %x
 }




More information about the llvm-commits mailing list