llvm.org GIT mirror llvm / 47a1522
[InstCombine] add tests for sext+ashr; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310935 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
1 changed file(s) with 58 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1919 ; CHECK-LABEL: @test2(
2020 ; CHECK-NEXT: [[TMP3:%.*]] = zext i8 %tmp to i32
2121 ; CHECK-NEXT: [[TMP4:%.*]] = add nuw nsw i32 [[TMP3]], 7
22 ; CHECK-NEXT: [[TMP51:%.*]] = lshr i32 [[TMP4]], 3
23 ; CHECK-NEXT: ret i32 [[TMP51]]
22 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP4]], 3
23 ; CHECK-NEXT: ret i32 [[TMP1]]
2424 ;
2525 %tmp3 = zext i8 %tmp to i32
2626 %tmp4 = add i32 %tmp3, 7
162162 ret <2 x i32> %sh2
163163 }
164164
165 ; TODO: Prefer a narrow shift for better for bit-tracking.
166 ; ashr (sext X), C --> sext (ashr X, C')
167
168 define i32 @hoist_ashr_ahead_of_sext_1(i8 %x) {
169 ; CHECK-LABEL: @hoist_ashr_ahead_of_sext_1(
170 ; CHECK-NEXT: [[SEXT:%.*]] = sext i8 %x to i32
171 ; CHECK-NEXT: [[R:%.*]] = ashr i32 [[SEXT]], 3
172 ; CHECK-NEXT: ret i32 [[R]]
173 ;
174 %sext = sext i8 %x to i32
175 %r = ashr i32 %sext, 3
176 ret i32 %r
177 }
178
179 ; TODO: Prefer a narrow shift for better for bit-tracking.
180 ; ashr (sext X), C --> sext (ashr X, C')
181
182 define <2 x i32> @hoist_ashr_ahead_of_sext_1_splat(<2 x i8> %x) {
183 ; CHECK-LABEL: @hoist_ashr_ahead_of_sext_1_splat(
184 ; CHECK-NEXT: [[SEXT:%.*]] = sext <2 x i8> %x to <2 x i32>
185 ; CHECK-NEXT: [[R:%.*]] = ashr <2 x i32> [[SEXT]],
186 ; CHECK-NEXT: ret <2 x i32> [[R]]
187 ;
188 %sext = sext <2 x i8> %x to <2 x i32>
189 %r = ashr <2 x i32> %sext,
190 ret <2 x i32> %r
191 }
192
193 ; TODO: Prefer a narrow shift for better for bit-tracking.
194 ; ashr (sext X), C --> sext (ashr X, C') -- the shift amount must be clamped
195
196 define i32 @hoist_ashr_ahead_of_sext_2(i8 %x) {
197 ; CHECK-LABEL: @hoist_ashr_ahead_of_sext_2(
198 ; CHECK-NEXT: [[SEXT:%.*]] = sext i8 %x to i32
199 ; CHECK-NEXT: [[R:%.*]] = ashr i32 [[SEXT]], 8
200 ; CHECK-NEXT: ret i32 [[R]]
201 ;
202 %sext = sext i8 %x to i32
203 %r = ashr i32 %sext, 8
204 ret i32 %r
205 }
206
207 ; TODO: Prefer a narrow shift for better for bit-tracking.
208 ; ashr (sext X), C --> sext (ashr X, C') -- the shift amount must be clamped
209
210 define <2 x i32> @hoist_ashr_ahead_of_sext_2_splat(<2 x i8> %x) {
211 ; CHECK-LABEL: @hoist_ashr_ahead_of_sext_2_splat(
212 ; CHECK-NEXT: [[SEXT:%.*]] = sext <2 x i8> %x to <2 x i32>
213 ; CHECK-NEXT: [[R:%.*]] = ashr <2 x i32> [[SEXT]],
214 ; CHECK-NEXT: ret <2 x i32> [[R]]
215 ;
216 %sext = sext <2 x i8> %x to <2 x i32>
217 %r = ashr <2 x i32> %sext,
218 ret <2 x i32> %r
219 }
220