OSDN Git Service

[X86] Add srem/udiv/urem by one combine tests
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 4 Jan 2018 22:08:36 +0000 (22:08 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 4 Jan 2018 22:08:36 +0000 (22:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321826 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/X86/combine-srem.ll
test/CodeGen/X86/combine-udiv.ll
test/CodeGen/X86/combine-urem.ll

index 3513e05..740bece 100644 (file)
@@ -38,6 +38,30 @@ define <4 x i32> @combine_vec_srem_undef1(<4 x i32> %x) {
   ret <4 x i32> %1
 }
 
+; fold (srem x, 1) -> 0
+define i32 @combine_srem_by_one(i32 %x) {
+; CHECK-LABEL: combine_srem_by_one:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    xorl %eax, %eax
+; CHECK-NEXT:    retq
+  %1 = srem i32 %x, 1
+  ret i32 %1
+}
+
+define <4 x i32> @combine_vec_srem_by_one(<4 x i32> %x) {
+; SSE-LABEL: combine_vec_srem_by_one:
+; SSE:       # %bb.0:
+; SSE-NEXT:    xorps %xmm0, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: combine_vec_srem_by_one:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vxorps %xmm0, %xmm0, %xmm0
+; AVX-NEXT:    retq
+  %1 = srem <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
+  ret <4 x i32> %1
+}
+
 ; TODO fold (srem x, x) -> 0
 define i32 @combine_srem_dupe(i32 %x) {
 ; CHECK-LABEL: combine_srem_dupe:
index 79054e7..7313091 100644 (file)
@@ -38,6 +38,24 @@ define <4 x i32> @combine_vec_udiv_undef1(<4 x i32> %x) {
   ret <4 x i32> %1
 }
 
+; fold (udiv x, 1) -> x
+define i32 @combine_udiv_by_one(i32 %x) {
+; CHECK-LABEL: combine_udiv_by_one:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movl %edi, %eax
+; CHECK-NEXT:    retq
+  %1 = udiv i32 %x, 1
+  ret i32 %1
+}
+
+define <4 x i32> @combine_vec_udiv_by_one(<4 x i32> %x) {
+; CHECK-LABEL: combine_vec_udiv_by_one:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    retq
+  %1 = udiv <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
+  ret <4 x i32> %1
+}
+
 ; TODO fold (udiv x, x) -> 1
 define i32 @combine_udiv_dupe(i32 %x) {
 ; CHECK-LABEL: combine_udiv_dupe:
index 4e316d6..b00bb3a 100644 (file)
@@ -38,6 +38,30 @@ define <4 x i32> @combine_vec_urem_undef1(<4 x i32> %x) {
   ret <4 x i32> %1
 }
 
+; fold (urem x, 1) -> 0
+define i32 @combine_urem_by_one(i32 %x) {
+; CHECK-LABEL: combine_urem_by_one:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    xorl %eax, %eax
+; CHECK-NEXT:    retq
+  %1 = urem i32 %x, 1
+  ret i32 %1
+}
+
+define <4 x i32> @combine_vec_urem_by_one(<4 x i32> %x) {
+; SSE-LABEL: combine_vec_urem_by_one:
+; SSE:       # %bb.0:
+; SSE-NEXT:    xorps %xmm0, %xmm0
+; SSE-NEXT:    retq
+;
+; AVX-LABEL: combine_vec_urem_by_one:
+; AVX:       # %bb.0:
+; AVX-NEXT:    vxorps %xmm0, %xmm0, %xmm0
+; AVX-NEXT:    retq
+  %1 = urem <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
+  ret <4 x i32> %1
+}
+
 ; TODO fold (urem x, x) -> 0
 define i32 @combine_urem_dupe(i32 %x) {
 ; CHECK-LABEL: combine_urem_dupe: