1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[InstCombine] add sub narrowing tests; NFC

This might be the root cause of PR35295:
https://bugs.llvm.org/show_bug.cgi?id=35295

llvm-svn: 318342
This commit is contained in:
Sanjay Patel 2017-11-15 22:19:55 +00:00
parent e4ccb8ba03
commit 0f6b54159f

View File

@ -96,6 +96,32 @@ define i16 @narrow_zext_add(i16 %x16, i32 %y32) {
ret i16 %r
}
define i16 @narrow_sext_sub(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_sub(
; CHECK-NEXT: [[X321:%.*]] = zext i16 %x16 to i32
; CHECK-NEXT: [[B:%.*]] = sub i32 [[X321]], %y32
; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = sext i16 %x16 to i32
%b = sub i32 %x32, %y32
%r = trunc i32 %b to i16
ret i16 %r
}
define i16 @narrow_zext_sub(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_zext_sub(
; CHECK-NEXT: [[X32:%.*]] = zext i16 %x16 to i32
; CHECK-NEXT: [[B:%.*]] = sub i32 [[X32]], %y32
; CHECK-NEXT: [[R:%.*]] = trunc i32 [[B]] to i16
; CHECK-NEXT: ret i16 [[R]]
;
%x32 = zext i16 %x16 to i32
%b = sub i32 %x32, %y32
%r = trunc i32 %b to i16
ret i16 %r
}
define i16 @narrow_sext_mul(i16 %x16, i32 %y32) {
; CHECK-LABEL: @narrow_sext_mul(
; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %y32 to i16
@ -235,6 +261,36 @@ define <2 x i16> @narrow_zext_add_commute(<2 x i16> %x16, <2 x i32> %y32) {
ret <2 x i16> %r
}
define <2 x i16> @narrow_sext_sub_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_sub_commute(
; CHECK-NEXT: [[Y32OP0:%.*]] = sdiv <2 x i32> %y32, <i32 7, i32 -17>
; CHECK-NEXT: [[X321:%.*]] = zext <2 x i16> %x16 to <2 x i32>
; CHECK-NEXT: [[B:%.*]] = sub <2 x i32> [[Y32OP0]], [[X321]]
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
%x32 = sext <2 x i16> %x16 to <2 x i32>
%b = sub <2 x i32> %y32op0, %x32
%r = trunc <2 x i32> %b to <2 x i16>
ret <2 x i16> %r
}
define <2 x i16> @narrow_zext_sub_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_zext_sub_commute(
; CHECK-NEXT: [[Y32OP0:%.*]] = sdiv <2 x i32> %y32, <i32 7, i32 -17>
; CHECK-NEXT: [[X32:%.*]] = zext <2 x i16> %x16 to <2 x i32>
; CHECK-NEXT: [[B:%.*]] = sub <2 x i32> [[Y32OP0]], [[X32]]
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i32> [[B]] to <2 x i16>
; CHECK-NEXT: ret <2 x i16> [[R]]
;
%y32op0 = sdiv <2 x i32> %y32, <i32 7, i32 -17>
%x32 = zext <2 x i16> %x16 to <2 x i32>
%b = sub <2 x i32> %y32op0, %x32
%r = trunc <2 x i32> %b to <2 x i16>
ret <2 x i16> %r
}
define <2 x i16> @narrow_sext_mul_commute(<2 x i16> %x16, <2 x i32> %y32) {
; CHECK-LABEL: @narrow_sext_mul_commute(
; CHECK-NEXT: [[Y32OP0:%.*]] = sdiv <2 x i32> %y32, <i32 7, i32 -17>