Skip to content

Commit ccf1038

Browse files
committed
[VectorCombine] Add tests where the index is guaranteed non-poison.
Tests for PR50949.
1 parent deaeb16 commit ccf1038

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

llvm/test/Transforms/VectorCombine/load-insert-store.ll

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,24 @@ entry:
254254

255255
declare void @llvm.assume(i1)
256256

257-
define void @insert_store_nonconst_index_known_valid_by_and(<16 x i8>* %q, i8 zeroext %s, i32 %idx) {
258-
; CHECK-LABEL: @insert_store_nonconst_index_known_valid_by_and(
257+
define void @insert_store_nonconst_index_known_noundef_and_valid_by_and(<16 x i8>* %q, i8 zeroext %s, i32 noundef %idx) {
258+
; CHECK-LABEL: @insert_store_nonconst_index_known_noundef_and_valid_by_and(
259+
; CHECK-NEXT: entry:
260+
; CHECK-NEXT: [[IDX_CLAMPED:%.*]] = and i32 [[IDX:%.*]], 7
261+
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* [[Q:%.*]], i32 0, i32 [[IDX_CLAMPED]]
262+
; CHECK-NEXT: store i8 [[S:%.*]], i8* [[TMP0]], align 1
263+
; CHECK-NEXT: ret void
264+
;
265+
entry:
266+
%0 = load <16 x i8>, <16 x i8>* %q
267+
%idx.clamped = and i32 %idx, 7
268+
%vecins = insertelement <16 x i8> %0, i8 %s, i32 %idx.clamped
269+
store <16 x i8> %vecins, <16 x i8>* %q
270+
ret void
271+
}
272+
273+
define void @insert_store_nonconst_index_known_valid_by_and_but_may_be_poison(<16 x i8>* %q, i8 zeroext %s, i32 %idx) {
274+
; CHECK-LABEL: @insert_store_nonconst_index_known_valid_by_and_but_may_be_poison(
259275
; CHECK-NEXT: entry:
260276
; CHECK-NEXT: [[IDX_CLAMPED:%.*]] = and i32 [[IDX:%.*]], 7
261277
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* [[Q:%.*]], i32 0, i32 [[IDX_CLAMPED]]
@@ -287,8 +303,24 @@ entry:
287303
ret void
288304
}
289305

290-
define void @insert_store_nonconst_index_known_valid_by_urem(<16 x i8>* %q, i8 zeroext %s, i32 %idx) {
291-
; CHECK-LABEL: @insert_store_nonconst_index_known_valid_by_urem(
306+
define void @insert_store_nonconst_index_known_noundef_and_valid_by_urem(<16 x i8>* %q, i8 zeroext %s, i32 noundef %idx) {
307+
; CHECK-LABEL: @insert_store_nonconst_index_known_noundef_and_valid_by_urem(
308+
; CHECK-NEXT: entry:
309+
; CHECK-NEXT: [[IDX_CLAMPED:%.*]] = urem i32 [[IDX:%.*]], 16
310+
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* [[Q:%.*]], i32 0, i32 [[IDX_CLAMPED]]
311+
; CHECK-NEXT: store i8 [[S:%.*]], i8* [[TMP0]], align 1
312+
; CHECK-NEXT: ret void
313+
;
314+
entry:
315+
%0 = load <16 x i8>, <16 x i8>* %q
316+
%idx.clamped = urem i32 %idx, 16
317+
%vecins = insertelement <16 x i8> %0, i8 %s, i32 %idx.clamped
318+
store <16 x i8> %vecins, <16 x i8>* %q
319+
ret void
320+
}
321+
322+
define void @insert_store_nonconst_index_known_valid_by_urem_but_may_be_poison(<16 x i8>* %q, i8 zeroext %s, i32 %idx) {
323+
; CHECK-LABEL: @insert_store_nonconst_index_known_valid_by_urem_but_may_be_poison(
292324
; CHECK-NEXT: entry:
293325
; CHECK-NEXT: [[IDX_CLAMPED:%.*]] = urem i32 [[IDX:%.*]], 16
294326
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <16 x i8>, <16 x i8>* [[Q:%.*]], i32 0, i32 [[IDX_CLAMPED]]

0 commit comments

Comments
 (0)