@@ -6,9 +6,9 @@ declare void @use8(i8)
6
6
7
7
define i6 @trunc_lshr (i8 %x ) {
8
8
; CHECK-LABEL: @trunc_lshr(
9
- ; CHECK-NEXT: [[TMP1 :%.*]] = trunc i8 [[X:%.*]] to i6
10
- ; CHECK-NEXT: [[TMP2 :%.*]] = lshr i6 [[TMP1]], 2
11
- ; CHECK-NEXT: [[R:%.*]] = and i6 [[TMP2 ]], 14
9
+ ; CHECK-NEXT: [[S :%.*]] = lshr i8 [[X:%.*]], 2
10
+ ; CHECK-NEXT: [[T :%.*]] = trunc i8 [[S]] to i6
11
+ ; CHECK-NEXT: [[R:%.*]] = and i6 [[T ]], 14
12
12
; CHECK-NEXT: ret i6 [[R]]
13
13
;
14
14
%s = lshr i8 %x , 2
@@ -17,22 +17,19 @@ define i6 @trunc_lshr(i8 %x) {
17
17
ret i6 %r
18
18
}
19
19
20
- ; The 'and' is eliminated.
21
-
22
20
define i6 @trunc_lshr_exact_mask (i8 %x ) {
23
21
; CHECK-LABEL: @trunc_lshr_exact_mask(
24
- ; CHECK-NEXT: [[TMP1:%.*]] = trunc i8 [[X:%.*]] to i6
25
- ; CHECK-NEXT: [[TMP2:%.*]] = lshr i6 [[TMP1]], 2
26
- ; CHECK-NEXT: ret i6 [[TMP2]]
22
+ ; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 2
23
+ ; CHECK-NEXT: [[T:%.*]] = trunc i8 [[S]] to i6
24
+ ; CHECK-NEXT: [[R:%.*]] = and i6 [[T]], 15
25
+ ; CHECK-NEXT: ret i6 [[R]]
27
26
;
28
27
%s = lshr i8 %x , 2
29
28
%t = trunc i8 %s to i6
30
29
%r = and i6 %t , 15
31
30
ret i6 %r
32
31
}
33
32
34
- ; negative test - a high bit of x is in the result
35
-
36
33
define i6 @trunc_lshr_big_mask (i8 %x ) {
37
34
; CHECK-LABEL: @trunc_lshr_big_mask(
38
35
; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 2
@@ -46,8 +43,6 @@ define i6 @trunc_lshr_big_mask(i8 %x) {
46
43
ret i6 %r
47
44
}
48
45
49
- ; negative test - too many uses
50
-
51
46
define i6 @trunc_lshr_use1 (i8 %x ) {
52
47
; CHECK-LABEL: @trunc_lshr_use1(
53
48
; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 2
@@ -63,8 +58,6 @@ define i6 @trunc_lshr_use1(i8 %x) {
63
58
ret i6 %r
64
59
}
65
60
66
- ; negative test - too many uses
67
-
68
61
define i6 @trunc_lshr_use2 (i8 %x ) {
69
62
; CHECK-LABEL: @trunc_lshr_use2(
70
63
; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 2
@@ -80,13 +73,11 @@ define i6 @trunc_lshr_use2(i8 %x) {
80
73
ret i6 %r
81
74
}
82
75
83
- ; Splat vectors are ok.
84
-
85
76
define <2 x i7 > @trunc_lshr_vec_splat (<2 x i16 > %x ) {
86
77
; CHECK-LABEL: @trunc_lshr_vec_splat(
87
- ; CHECK-NEXT: [[TMP1 :%.*]] = trunc <2 x i16> [[X:%.*]] to <2 x i7 >
88
- ; CHECK-NEXT: [[TMP2 :%.*]] = lshr <2 x i7 > [[TMP1]], <i7 5, i7 5 >
89
- ; CHECK-NEXT: [[R:%.*]] = and <2 x i7> [[TMP2 ]], <i7 1, i7 1>
78
+ ; CHECK-NEXT: [[S :%.*]] = lshr <2 x i16> [[X:%.*]], <i16 5, i16 5 >
79
+ ; CHECK-NEXT: [[T :%.*]] = trunc <2 x i16 > [[S]] to <2 x i7>
80
+ ; CHECK-NEXT: [[R:%.*]] = and <2 x i7> [[T ]], <i7 1, i7 1>
90
81
; CHECK-NEXT: ret <2 x i7> [[R]]
91
82
;
92
83
%s = lshr <2 x i16 > %x , <i16 5 , i16 5 >
@@ -95,22 +86,19 @@ define <2 x i7> @trunc_lshr_vec_splat(<2 x i16> %x) {
95
86
ret <2 x i7 > %r
96
87
}
97
88
98
- ; The 'and' is eliminated.
99
-
100
89
define <2 x i7 > @trunc_lshr_vec_splat_exact_mask (<2 x i16 > %x ) {
101
90
; CHECK-LABEL: @trunc_lshr_vec_splat_exact_mask(
102
- ; CHECK-NEXT: [[TMP1:%.*]] = trunc <2 x i16> [[X:%.*]] to <2 x i7>
103
- ; CHECK-NEXT: [[TMP2:%.*]] = lshr <2 x i7> [[TMP1]], <i7 6, i7 6>
104
- ; CHECK-NEXT: ret <2 x i7> [[TMP2]]
91
+ ; CHECK-NEXT: [[S:%.*]] = lshr <2 x i16> [[X:%.*]], <i16 6, i16 6>
92
+ ; CHECK-NEXT: [[T:%.*]] = trunc <2 x i16> [[S]] to <2 x i7>
93
+ ; CHECK-NEXT: [[R:%.*]] = and <2 x i7> [[T]], <i7 1, i7 1>
94
+ ; CHECK-NEXT: ret <2 x i7> [[R]]
105
95
;
106
96
%s = lshr <2 x i16 > %x , <i16 6 , i16 6 >
107
97
%t = trunc <2 x i16 > %s to <2 x i7 >
108
98
%r = and <2 x i7 > %t , <i7 1 , i7 1 >
109
99
ret <2 x i7 > %r
110
100
}
111
101
112
- ; negative test - the shift is too big for the narrow type
113
-
114
102
define <2 x i7 > @trunc_lshr_big_shift (<2 x i16 > %x ) {
115
103
; CHECK-LABEL: @trunc_lshr_big_shift(
116
104
; CHECK-NEXT: [[S:%.*]] = lshr <2 x i16> [[X:%.*]], <i16 7, i16 7>
@@ -124,13 +112,11 @@ define <2 x i7> @trunc_lshr_big_shift(<2 x i16> %x) {
124
112
ret <2 x i7 > %r
125
113
}
126
114
127
- ; High bits could also be set rather than cleared.
128
-
129
115
define i6 @or_trunc_lshr (i8 %x ) {
130
116
; CHECK-LABEL: @or_trunc_lshr(
131
- ; CHECK-NEXT: [[TMP1 :%.*]] = trunc i8 [[X:%.*]] to i6
132
- ; CHECK-NEXT: [[TMP2 :%.*]] = lshr i6 [[TMP1]], 1
133
- ; CHECK-NEXT: [[R:%.*]] = or i6 [[TMP2 ]], -32
117
+ ; CHECK-NEXT: [[S :%.*]] = lshr i8 [[X:%.*]], 1
118
+ ; CHECK-NEXT: [[T :%.*]] = trunc i8 [[S]] to i6
119
+ ; CHECK-NEXT: [[R:%.*]] = or i6 [[T ]], -32
134
120
; CHECK-NEXT: ret i6 [[R]]
135
121
;
136
122
%s = lshr i8 %x , 1
@@ -141,9 +127,9 @@ define i6 @or_trunc_lshr(i8 %x) {
141
127
142
128
define i6 @or_trunc_lshr_more (i8 %x ) {
143
129
; CHECK-LABEL: @or_trunc_lshr_more(
144
- ; CHECK-NEXT: [[TMP1 :%.*]] = trunc i8 [[X:%.*]] to i6
145
- ; CHECK-NEXT: [[TMP2 :%.*]] = lshr i6 [[TMP1]], 4
146
- ; CHECK-NEXT: [[R:%.*]] = or i6 [[TMP2 ]], -4
130
+ ; CHECK-NEXT: [[S :%.*]] = lshr i8 [[X:%.*]], 4
131
+ ; CHECK-NEXT: [[T :%.*]] = trunc i8 [[S]] to i6
132
+ ; CHECK-NEXT: [[R:%.*]] = or i6 [[T ]], -4
147
133
; CHECK-NEXT: ret i6 [[R]]
148
134
;
149
135
%s = lshr i8 %x , 4
@@ -152,8 +138,6 @@ define i6 @or_trunc_lshr_more(i8 %x) {
152
138
ret i6 %r
153
139
}
154
140
155
- ; negative test - need all high bits to be undemanded
156
-
157
141
define i6 @or_trunc_lshr_small_mask (i8 %x ) {
158
142
; CHECK-LABEL: @or_trunc_lshr_small_mask(
159
143
; CHECK-NEXT: [[S:%.*]] = lshr i8 [[X:%.*]], 4
0 commit comments