[X86] Add scalar undef sdiv/srem/udiv/urem combine tests

llvm-svn: 321823
This commit is contained in:
Simon Pilgrim 2018-01-04 21:33:19 +00:00
parent 7212b6e4b9
commit e7c06423c1
4 changed files with 87 additions and 0 deletions

View File

@ -4,6 +4,15 @@
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2
; fold (sdiv undef, x) -> 0 ; fold (sdiv undef, x) -> 0
define i32 @combine_sdiv_undef0(i32 %x) {
; CHECK-LABEL: combine_sdiv_undef0:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%1 = sdiv i32 undef, %x
ret i32 %1
}
define <4 x i32> @combine_vec_sdiv_undef0(<4 x i32> %x) { define <4 x i32> @combine_vec_sdiv_undef0(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_sdiv_undef0: ; CHECK-LABEL: combine_vec_sdiv_undef0:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -13,6 +22,14 @@ define <4 x i32> @combine_vec_sdiv_undef0(<4 x i32> %x) {
} }
; fold (sdiv x, undef) -> undef ; fold (sdiv x, undef) -> undef
define i32 @combine_sdiv_undef1(i32 %x) {
; CHECK-LABEL: combine_sdiv_undef1:
; CHECK: # %bb.0:
; CHECK-NEXT: retq
%1 = sdiv i32 %x, undef
ret i32 %1
}
define <4 x i32> @combine_vec_sdiv_undef1(<4 x i32> %x) { define <4 x i32> @combine_vec_sdiv_undef1(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_sdiv_undef1: ; CHECK-LABEL: combine_vec_sdiv_undef1:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -22,6 +39,15 @@ define <4 x i32> @combine_vec_sdiv_undef1(<4 x i32> %x) {
} }
; fold (sdiv x, 1) -> x ; fold (sdiv x, 1) -> x
define i32 @combine_sdiv_by_one(i32 %x) {
; CHECK-LABEL: combine_sdiv_by_one:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: retq
%1 = sdiv i32 %x, 1
ret i32 %1
}
define <4 x i32> @combine_vec_sdiv_by_one(<4 x i32> %x) { define <4 x i32> @combine_vec_sdiv_by_one(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_sdiv_by_one: ; CHECK-LABEL: combine_vec_sdiv_by_one:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -31,6 +57,16 @@ define <4 x i32> @combine_vec_sdiv_by_one(<4 x i32> %x) {
} }
; fold (sdiv x, -1) -> 0 - x ; fold (sdiv x, -1) -> 0 - x
define i32 @combine_sdiv_by_negone(i32 %x) {
; CHECK-LABEL: combine_sdiv_by_negone:
; CHECK: # %bb.0:
; CHECK-NEXT: negl %edi
; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: retq
%1 = sdiv i32 %x, -1
ret i32 %1
}
define <4 x i32> @combine_vec_sdiv_by_negone(<4 x i32> %x) { define <4 x i32> @combine_vec_sdiv_by_negone(<4 x i32> %x) {
; SSE-LABEL: combine_vec_sdiv_by_negone: ; SSE-LABEL: combine_vec_sdiv_by_negone:
; SSE: # %bb.0: ; SSE: # %bb.0:

View File

@ -4,6 +4,15 @@
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2
; fold (srem undef, x) -> 0 ; fold (srem undef, x) -> 0
define i32 @combine_srem_undef0(i32 %x) {
; CHECK-LABEL: combine_srem_undef0:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%1 = srem i32 undef, %x
ret i32 %1
}
define <4 x i32> @combine_vec_srem_undef0(<4 x i32> %x) { define <4 x i32> @combine_vec_srem_undef0(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_srem_undef0: ; CHECK-LABEL: combine_vec_srem_undef0:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -13,6 +22,14 @@ define <4 x i32> @combine_vec_srem_undef0(<4 x i32> %x) {
} }
; fold (srem x, undef) -> undef ; fold (srem x, undef) -> undef
define i32 @combine_srem_undef1(i32 %x) {
; CHECK-LABEL: combine_srem_undef1:
; CHECK: # %bb.0:
; CHECK-NEXT: retq
%1 = srem i32 %x, undef
ret i32 %1
}
define <4 x i32> @combine_vec_srem_undef1(<4 x i32> %x) { define <4 x i32> @combine_vec_srem_undef1(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_srem_undef1: ; CHECK-LABEL: combine_vec_srem_undef1:
; CHECK: # %bb.0: ; CHECK: # %bb.0:

View File

@ -4,6 +4,15 @@
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2
; fold (udiv undef, x) -> 0 ; fold (udiv undef, x) -> 0
define i32 @combine_udiv_undef0(i32 %x) {
; CHECK-LABEL: combine_udiv_undef0:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%1 = udiv i32 undef, %x
ret i32 %1
}
define <4 x i32> @combine_vec_udiv_undef0(<4 x i32> %x) { define <4 x i32> @combine_vec_udiv_undef0(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_udiv_undef0: ; CHECK-LABEL: combine_vec_udiv_undef0:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -13,6 +22,14 @@ define <4 x i32> @combine_vec_udiv_undef0(<4 x i32> %x) {
} }
; fold (udiv x, undef) -> undef ; fold (udiv x, undef) -> undef
define i32 @combine_udiv_undef1(i32 %x) {
; CHECK-LABEL: combine_udiv_undef1:
; CHECK: # %bb.0:
; CHECK-NEXT: retq
%1 = udiv i32 %x, undef
ret i32 %1
}
define <4 x i32> @combine_vec_udiv_undef1(<4 x i32> %x) { define <4 x i32> @combine_vec_udiv_undef1(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_udiv_undef1: ; CHECK-LABEL: combine_vec_udiv_undef1:
; CHECK: # %bb.0: ; CHECK: # %bb.0:

View File

@ -4,6 +4,15 @@
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX --check-prefix=AVX2
; fold (urem undef, x) -> 0 ; fold (urem undef, x) -> 0
define i32 @combine_urem_undef0(i32 %x) {
; CHECK-LABEL: combine_urem_undef0:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: retq
%1 = urem i32 undef, %x
ret i32 %1
}
define <4 x i32> @combine_vec_urem_undef0(<4 x i32> %x) { define <4 x i32> @combine_vec_urem_undef0(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_urem_undef0: ; CHECK-LABEL: combine_vec_urem_undef0:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -13,6 +22,14 @@ define <4 x i32> @combine_vec_urem_undef0(<4 x i32> %x) {
} }
; fold (urem x, undef) -> undef ; fold (urem x, undef) -> undef
define i32 @combine_urem_undef1(i32 %x) {
; CHECK-LABEL: combine_urem_undef1:
; CHECK: # %bb.0:
; CHECK-NEXT: retq
%1 = urem i32 %x, undef
ret i32 %1
}
define <4 x i32> @combine_vec_urem_undef1(<4 x i32> %x) { define <4 x i32> @combine_vec_urem_undef1(<4 x i32> %x) {
; CHECK-LABEL: combine_vec_urem_undef1: ; CHECK-LABEL: combine_vec_urem_undef1:
; CHECK: # %bb.0: ; CHECK: # %bb.0: