[InstSimplify] add tests for funnel shift with select; NFC

llvm-svn: 346881
This commit is contained in:
Sanjay Patel 2018-11-14 19:12:54 +00:00
parent e4afbc6804
commit 7d028670f6
1 changed files with 65 additions and 0 deletions

View File

@ -500,3 +500,68 @@ define <2 x i8> @fshr_no_shift_modulo_bitwidth_splat(<2 x i8> %x, <2 x i8> %y) {
ret <2 x i8> %z
}
define i8 @fshl_zero_shift_guard(i8 %x, i8 %y, i8 %sh) {
; CHECK-LABEL: @fshl_zero_shift_guard(
; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[SH:%.*]], 0
; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[SH]])
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[F]]
; CHECK-NEXT: ret i8 [[S]]
;
%c = icmp eq i8 %sh, 0
%f = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %sh)
%s = select i1 %c, i8 %x, i8 %f
ret i8 %s
}
define i9 @fshr_zero_shift_guard_swapped(i9 %x, i9 %y, i9 %sh) {
; CHECK-LABEL: @fshr_zero_shift_guard_swapped(
; CHECK-NEXT: [[C:%.*]] = icmp ne i9 [[SH:%.*]], 0
; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 [[SH]])
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i9 [[F]], i9 [[Y]]
; CHECK-NEXT: ret i9 [[S]]
;
%c = icmp ne i9 %sh, 0
%f = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 %sh)
%s = select i1 %c, i9 %f, i9 %y
ret i9 %s
}
define i8 @fshl_zero_shift_guard_wrong_select_op(i8 %x, i8 %y, i8 %sh) {
; CHECK-LABEL: @fshl_zero_shift_guard_wrong_select_op(
; CHECK-NEXT: [[C:%.*]] = icmp eq i8 [[SH:%.*]], 0
; CHECK-NEXT: [[F:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[SH]])
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[Y]], i8 [[F]]
; CHECK-NEXT: ret i8 [[S]]
;
%c = icmp eq i8 %sh, 0
%f = call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %sh)
%s = select i1 %c, i8 %y, i8 %f
ret i8 %s
}
define i9 @fshr_zero_shift_guard_swapped_select_order(i9 %x, i9 %y, i9 %sh) {
; CHECK-LABEL: @fshr_zero_shift_guard_swapped_select_order(
; CHECK-NEXT: [[C:%.*]] = icmp eq i9 [[SH:%.*]], 0
; CHECK-NEXT: [[F:%.*]] = call i9 @llvm.fshr.i9(i9 [[X:%.*]], i9 [[Y:%.*]], i9 [[SH]])
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i9 [[F]], i9 [[Y]]
; CHECK-NEXT: ret i9 [[S]]
;
%c = icmp eq i9 %sh, 0
%f = call i9 @llvm.fshr.i9(i9 %x, i9 %y, i9 %sh)
%s = select i1 %c, i9 %f, i9 %y
ret i9 %s
}
define <2 x i8> @fshr_zero_shift_guard_splat(<2 x i8> %x, <2 x i8> %y, <2 x i8> %sh) {
; CHECK-LABEL: @fshr_zero_shift_guard_splat(
; CHECK-NEXT: [[C:%.*]] = icmp eq <2 x i8> [[SH:%.*]], zeroinitializer
; CHECK-NEXT: [[F:%.*]] = call <2 x i8> @llvm.fshr.v2i8(<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]], <2 x i8> [[SH]])
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[C]], <2 x i8> [[Y]], <2 x i8> [[F]]
; CHECK-NEXT: ret <2 x i8> [[S]]
;
%c = icmp eq <2 x i8> %sh, zeroinitializer
%f = call <2 x i8> @llvm.fshr.v2i8(<2 x i8> %x, <2 x i8> %y, <2 x i8> %sh)
%s = select <2 x i1> %c, <2 x i8> %y, <2 x i8> %f
ret <2 x i8> %s
}