[InstSimplify] add tests for div/rem with bool divisor; NFC

llvm-svn: 335509
This commit is contained in:
Sanjay Patel 2018-06-25 18:27:14 +00:00
parent 88fee5fdbc
commit a46bcbec58
2 changed files with 44 additions and 0 deletions

View File

@ -95,6 +95,28 @@ define <2 x i1> @udiv_bool_vec(<2 x i1> %x, <2 x i1> %y) {
ret <2 x i1> %div
}
define i32 @zext_bool_udiv_divisor(i1 %x, i32 %y) {
; CHECK-LABEL: @zext_bool_udiv_divisor(
; CHECK-NEXT: [[EXT:%.*]] = zext i1 [[X:%.*]] to i32
; CHECK-NEXT: [[R:%.*]] = udiv i32 [[Y:%.*]], [[EXT]]
; CHECK-NEXT: ret i32 [[R]]
;
%ext = zext i1 %x to i32
%r = udiv i32 %y, %ext
ret i32 %r
}
define <2 x i32> @zext_bool_sdiv_divisor_vec(<2 x i1> %x, <2 x i32> %y) {
; CHECK-LABEL: @zext_bool_sdiv_divisor_vec(
; CHECK-NEXT: [[EXT:%.*]] = zext <2 x i1> [[X:%.*]] to <2 x i32>
; CHECK-NEXT: [[R:%.*]] = sdiv <2 x i32> [[Y:%.*]], [[EXT]]
; CHECK-NEXT: ret <2 x i32> [[R]]
;
%ext = zext <2 x i1> %x to <2 x i32>
%r = sdiv <2 x i32> %y, %ext
ret <2 x i32> %r
}
define i32 @udiv_dividend_known_smaller_than_constant_divisor(i32 %x) {
; CHECK-LABEL: @udiv_dividend_known_smaller_than_constant_divisor(
; CHECK-NEXT: ret i32 0

View File

@ -95,6 +95,28 @@ define <2 x i1> @urem_bool_vec(<2 x i1> %x, <2 x i1> %y) {
ret <2 x i1> %rem
}
define <2 x i32> @zext_bool_urem_divisor_vec(<2 x i1> %x, <2 x i32> %y) {
; CHECK-LABEL: @zext_bool_urem_divisor_vec(
; CHECK-NEXT: [[EXT:%.*]] = zext <2 x i1> [[X:%.*]] to <2 x i32>
; CHECK-NEXT: [[R:%.*]] = urem <2 x i32> [[Y:%.*]], [[EXT]]
; CHECK-NEXT: ret <2 x i32> [[R]]
;
%ext = zext <2 x i1> %x to <2 x i32>
%r = urem <2 x i32> %y, %ext
ret <2 x i32> %r
}
define i32 @zext_bool_srem_divisor(i1 %x, i32 %y) {
; CHECK-LABEL: @zext_bool_srem_divisor(
; CHECK-NEXT: [[EXT:%.*]] = zext i1 [[X:%.*]] to i32
; CHECK-NEXT: [[R:%.*]] = srem i32 [[Y:%.*]], [[EXT]]
; CHECK-NEXT: ret i32 [[R]]
;
%ext = zext i1 %x to i32
%r = srem i32 %y, %ext
ret i32 %r
}
define i32 @select1(i32 %x, i1 %b) {
; CHECK-LABEL: @select1(
; CHECK-NEXT: ret i32 0