[llvm] r321826 - [X86] Add srem/udiv/urem by one combine tests
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 14:08:36 PST 2018
Author: rksimon
Date: Thu Jan 4 14:08:36 2018
New Revision: 321826
URL: http://llvm.org/viewvc/llvm-project?rev=321826&view=rev
Log:
[X86] Add srem/udiv/urem by one combine tests
Modified:
llvm/trunk/test/CodeGen/X86/combine-srem.ll
llvm/trunk/test/CodeGen/X86/combine-udiv.ll
llvm/trunk/test/CodeGen/X86/combine-urem.ll
Modified: llvm/trunk/test/CodeGen/X86/combine-srem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/combine-srem.ll?rev=321826&r1=321825&r2=321826&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/combine-srem.ll (original)
+++ llvm/trunk/test/CodeGen/X86/combine-srem.ll Thu Jan 4 14:08:36 2018
@@ -38,6 +38,30 @@ define <4 x i32> @combine_vec_srem_undef
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:
Modified: llvm/trunk/test/CodeGen/X86/combine-udiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/combine-udiv.ll?rev=321826&r1=321825&r2=321826&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/combine-udiv.ll (original)
+++ llvm/trunk/test/CodeGen/X86/combine-udiv.ll Thu Jan 4 14:08:36 2018
@@ -38,6 +38,24 @@ define <4 x i32> @combine_vec_udiv_undef
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:
Modified: llvm/trunk/test/CodeGen/X86/combine-urem.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/combine-urem.ll?rev=321826&r1=321825&r2=321826&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/combine-urem.ll (original)
+++ llvm/trunk/test/CodeGen/X86/combine-urem.ll Thu Jan 4 14:08:36 2018
@@ -38,6 +38,30 @@ define <4 x i32> @combine_vec_urem_undef
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:
More information about the llvm-commits
mailing list