@@ -2126,3 +2126,75 @@ define <2 x i8> @ashr_vec_or6_fail(<2 x i8> %x, <2 x i8> %c) {
2126
2126
%y = ashr <2 x i8 > %x , %amt
2127
2127
ret <2 x i8 > %y
2128
2128
}
2129
+
2130
+ define i16 @lshr_and_not_demanded (i8 %x ) {
2131
+ ; CHECK-LABEL: @lshr_and_not_demanded(
2132
+ ; CHECK-NEXT: [[Y_EXT:%.*]] = sext i8 [[X:%.*]] to i16
2133
+ ; CHECK-NEXT: [[SHR:%.*]] = lshr i16 [[Y_EXT]], 1
2134
+ ; CHECK-NEXT: ret i16 [[SHR]]
2135
+ ;
2136
+ %y = and i8 %x , -2
2137
+ %y.ext = sext i8 %y to i16
2138
+ %shr = lshr i16 %y.ext , 1
2139
+ ret i16 %shr
2140
+ }
2141
+
2142
+ define i16 @lshr_exact_and_not_demanded (i8 %x ) {
2143
+ ; CHECK-LABEL: @lshr_exact_and_not_demanded(
2144
+ ; CHECK-NEXT: [[Y:%.*]] = and i8 [[X:%.*]], -2
2145
+ ; CHECK-NEXT: [[Y_EXT:%.*]] = sext i8 [[Y]] to i16
2146
+ ; CHECK-NEXT: [[SHR:%.*]] = lshr exact i16 [[Y_EXT]], 1
2147
+ ; CHECK-NEXT: ret i16 [[SHR]]
2148
+ ;
2149
+ %y = and i8 %x , -2
2150
+ %y.ext = sext i8 %y to i16
2151
+ %shr = lshr exact i16 %y.ext , 1
2152
+ ret i16 %shr
2153
+ }
2154
+
2155
+ define i16 @lshr_and_demanded (i8 %x ) {
2156
+ ; CHECK-LABEL: @lshr_and_demanded(
2157
+ ; CHECK-NEXT: [[Y:%.*]] = and i8 [[X:%.*]], -4
2158
+ ; CHECK-NEXT: [[Y_EXT:%.*]] = sext i8 [[Y]] to i16
2159
+ ; CHECK-NEXT: [[SHR:%.*]] = lshr exact i16 [[Y_EXT]], 1
2160
+ ; CHECK-NEXT: ret i16 [[SHR]]
2161
+ ;
2162
+ %y = and i8 %x , -4
2163
+ %y.ext = sext i8 %y to i16
2164
+ %shr = lshr i16 %y.ext , 1
2165
+ ret i16 %shr
2166
+ }
2167
+
2168
+ define i16 @ashr_umax_not_demanded (i16 %x ) {
2169
+ ; CHECK-LABEL: @ashr_umax_not_demanded(
2170
+ ; CHECK-NEXT: [[SHR:%.*]] = ashr i16 [[X:%.*]], 1
2171
+ ; CHECK-NEXT: ret i16 [[SHR]]
2172
+ ;
2173
+ %y = call i16 @llvm.umax.i16 (i16 %x , i16 1 )
2174
+ %shr = ashr i16 %y , 1
2175
+ ret i16 %shr
2176
+ }
2177
+
2178
+ define i16 @ashr_exact_umax_not_demanded (i16 %x ) {
2179
+ ; CHECK-LABEL: @ashr_exact_umax_not_demanded(
2180
+ ; CHECK-NEXT: [[Y:%.*]] = call i16 @llvm.umax.i16(i16 [[X:%.*]], i16 1)
2181
+ ; CHECK-NEXT: [[SHR:%.*]] = ashr exact i16 [[Y]], 1
2182
+ ; CHECK-NEXT: ret i16 [[SHR]]
2183
+ ;
2184
+ %y = call i16 @llvm.umax.i16 (i16 %x , i16 1 )
2185
+ %shr = ashr exact i16 %y , 1
2186
+ ret i16 %shr
2187
+ }
2188
+
2189
+ define i16 @ashr_umax_demanded (i16 %x ) {
2190
+ ; CHECK-LABEL: @ashr_umax_demanded(
2191
+ ; CHECK-NEXT: [[Y:%.*]] = call i16 @llvm.umax.i16(i16 [[X:%.*]], i16 2)
2192
+ ; CHECK-NEXT: [[SHR:%.*]] = ashr i16 [[Y]], 1
2193
+ ; CHECK-NEXT: ret i16 [[SHR]]
2194
+ ;
2195
+ %y = call i16 @llvm.umax.i16 (i16 %x , i16 2 )
2196
+ %shr = ashr i16 %y , 1
2197
+ ret i16 %shr
2198
+ }
2199
+
2200
+ declare i16 @llvm.umax.i16 (i16 , i16 )
0 commit comments