3
3
4
4
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
5
5
6
- ; TODO: Canonicalize or(shl,lshr) by constant to funnel shift intrinsics.
6
+ ; Canonicalize or(shl,lshr) by constant to funnel shift intrinsics.
7
7
; This should help cost modeling for vectorization, inlining, etc.
8
8
; If a target does not have a fshl instruction, the expansion will
9
9
; be exactly these same 3 basic ops (shl/lshr/or).
10
10
11
11
define i32 @fshl_i32_constant (i32 %x , i32 %y ) {
12
12
; CHECK-LABEL: @fshl_i32_constant(
13
- ; CHECK-NEXT: [[SHL:%.*]] = shl i32 [[X:%.*]], 11
14
- ; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[Y:%.*]], 21
15
- ; CHECK-NEXT: [[R:%.*]] = or i32 [[SHR]], [[SHL]]
13
+ ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[Y:%.*]], i32 11)
16
14
; CHECK-NEXT: ret i32 [[R]]
17
15
;
18
16
%shl = shl i32 %x , 11
@@ -23,9 +21,7 @@ define i32 @fshl_i32_constant(i32 %x, i32 %y) {
23
21
24
22
define i42 @fshr_i42_constant (i42 %x , i42 %y ) {
25
23
; CHECK-LABEL: @fshr_i42_constant(
26
- ; CHECK-NEXT: [[SHR:%.*]] = lshr i42 [[X:%.*]], 31
27
- ; CHECK-NEXT: [[SHL:%.*]] = shl i42 [[Y:%.*]], 11
28
- ; CHECK-NEXT: [[R:%.*]] = or i42 [[SHR]], [[SHL]]
24
+ ; CHECK-NEXT: [[R:%.*]] = call i42 @llvm.fshl.i42(i42 [[Y:%.*]], i42 [[X:%.*]], i42 11)
29
25
; CHECK-NEXT: ret i42 [[R]]
30
26
;
31
27
%shr = lshr i42 %x , 31
@@ -34,13 +30,11 @@ define i42 @fshr_i42_constant(i42 %x, i42 %y) {
34
30
ret i42 %r
35
31
}
36
32
37
- ; TODO: Vector types are allowed.
33
+ ; Vector types are allowed.
38
34
39
35
define <2 x i16 > @fshl_v2i16_constant_splat (<2 x i16 > %x , <2 x i16 > %y ) {
40
36
; CHECK-LABEL: @fshl_v2i16_constant_splat(
41
- ; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i16> [[X:%.*]], <i16 1, i16 1>
42
- ; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i16> [[Y:%.*]], <i16 15, i16 15>
43
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[SHL]], [[SHR]]
37
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i16> @llvm.fshl.v2i16(<2 x i16> [[X:%.*]], <2 x i16> [[Y:%.*]], <2 x i16> <i16 1, i16 1>)
44
38
; CHECK-NEXT: ret <2 x i16> [[R]]
45
39
;
46
40
%shl = shl <2 x i16 > %x , <i16 1 , i16 1 >
@@ -51,9 +45,7 @@ define <2 x i16> @fshl_v2i16_constant_splat(<2 x i16> %x, <2 x i16> %y) {
51
45
52
46
define <2 x i16 > @fshl_v2i16_constant_splat_undef0 (<2 x i16 > %x , <2 x i16 > %y ) {
53
47
; CHECK-LABEL: @fshl_v2i16_constant_splat_undef0(
54
- ; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i16> [[X:%.*]], <i16 undef, i16 1>
55
- ; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i16> [[Y:%.*]], <i16 15, i16 15>
56
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[SHL]], [[SHR]]
48
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i16> @llvm.fshl.v2i16(<2 x i16> [[X:%.*]], <2 x i16> [[Y:%.*]], <2 x i16> <i16 1, i16 1>)
57
49
; CHECK-NEXT: ret <2 x i16> [[R]]
58
50
;
59
51
%shl = shl <2 x i16 > %x , <i16 undef , i16 1 >
@@ -64,9 +56,7 @@ define <2 x i16> @fshl_v2i16_constant_splat_undef0(<2 x i16> %x, <2 x i16> %y) {
64
56
65
57
define <2 x i16 > @fshl_v2i16_constant_splat_undef1 (<2 x i16 > %x , <2 x i16 > %y ) {
66
58
; CHECK-LABEL: @fshl_v2i16_constant_splat_undef1(
67
- ; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i16> [[X:%.*]], <i16 1, i16 1>
68
- ; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i16> [[Y:%.*]], <i16 15, i16 undef>
69
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[SHL]], [[SHR]]
59
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i16> @llvm.fshl.v2i16(<2 x i16> [[X:%.*]], <2 x i16> [[Y:%.*]], <2 x i16> <i16 1, i16 1>)
70
60
; CHECK-NEXT: ret <2 x i16> [[R]]
71
61
;
72
62
%shl = shl <2 x i16 > %x , <i16 1 , i16 1 >
@@ -75,13 +65,11 @@ define <2 x i16> @fshl_v2i16_constant_splat_undef1(<2 x i16> %x, <2 x i16> %y) {
75
65
ret <2 x i16 > %r
76
66
}
77
67
78
- ; TODO: Non-power-of-2 vector types are allowed.
68
+ ; Non-power-of-2 vector types are allowed.
79
69
80
70
define <2 x i17 > @fshr_v2i17_constant_splat (<2 x i17 > %x , <2 x i17 > %y ) {
81
71
; CHECK-LABEL: @fshr_v2i17_constant_splat(
82
- ; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i17> [[X:%.*]], <i17 12, i17 12>
83
- ; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i17> [[Y:%.*]], <i17 5, i17 5>
84
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i17> [[SHR]], [[SHL]]
72
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i17> @llvm.fshl.v2i17(<2 x i17> [[Y:%.*]], <2 x i17> [[X:%.*]], <2 x i17> <i17 5, i17 5>)
85
73
; CHECK-NEXT: ret <2 x i17> [[R]]
86
74
;
87
75
%shr = lshr <2 x i17 > %x , <i17 12 , i17 12 >
@@ -92,9 +80,7 @@ define <2 x i17> @fshr_v2i17_constant_splat(<2 x i17> %x, <2 x i17> %y) {
92
80
93
81
define <2 x i17 > @fshr_v2i17_constant_splat_undef0 (<2 x i17 > %x , <2 x i17 > %y ) {
94
82
; CHECK-LABEL: @fshr_v2i17_constant_splat_undef0(
95
- ; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i17> [[X:%.*]], <i17 12, i17 undef>
96
- ; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i17> [[Y:%.*]], <i17 undef, i17 5>
97
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i17> [[SHR]], [[SHL]]
83
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i17> @llvm.fshl.v2i17(<2 x i17> [[Y:%.*]], <2 x i17> [[X:%.*]], <2 x i17> <i17 5, i17 5>)
98
84
; CHECK-NEXT: ret <2 x i17> [[R]]
99
85
;
100
86
%shr = lshr <2 x i17 > %x , <i17 12 , i17 undef >
@@ -105,9 +91,7 @@ define <2 x i17> @fshr_v2i17_constant_splat_undef0(<2 x i17> %x, <2 x i17> %y) {
105
91
106
92
define <2 x i17 > @fshr_v2i17_constant_splat_undef1 (<2 x i17 > %x , <2 x i17 > %y ) {
107
93
; CHECK-LABEL: @fshr_v2i17_constant_splat_undef1(
108
- ; CHECK-NEXT: [[SHR:%.*]] = lshr <2 x i17> [[X:%.*]], <i17 12, i17 undef>
109
- ; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i17> [[Y:%.*]], <i17 5, i17 undef>
110
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i17> [[SHR]], [[SHL]]
94
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i17> @llvm.fshl.v2i17(<2 x i17> [[Y:%.*]], <2 x i17> [[X:%.*]], <2 x i17> <i17 5, i17 5>)
111
95
; CHECK-NEXT: ret <2 x i17> [[R]]
112
96
;
113
97
%shr = lshr <2 x i17 > %x , <i17 12 , i17 undef >
0 commit comments