Skip to content

Commit 7b3fe5f

Browse files
authored
[LV][NFC] Remove undef values in some test cases (#164401)
Split off from PR #163525, this standalone patch replaces simple cases where undef is used as a value for arithmetic or getelementptr instructions. This will reduce the likelihood of contributors hitting the `undef deprecator` warning in github.
1 parent 8eacea9 commit 7b3fe5f

13 files changed

+121
-98
lines changed

llvm/test/Transforms/LoopVectorize/X86/consecutive-ptr-cg-bug.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ target triple = "x86_64-unknown-linux-gnu"
3535
; This test was originally vectorized, but now SCEV is smart enough to prove
3636
; that its trip count is 1, so it gets ignored by vectorizer.
3737
; Function Attrs: uwtable
38-
define void @test_01(i1 %arg) {
38+
define void @test_01(ptr addrspace(1) %p, i1 %arg) {
3939
br label %.outer
4040

4141
; <label>:1: ; preds = %2
@@ -57,8 +57,8 @@ define void @test_01(i1 %arg) {
5757
%8 = phi i32 [ %.ph2, %.outer ], [ %7, %6 ]
5858
%9 = add i32 %8, 2
5959
%10 = zext i32 %9 to i64
60-
%11 = getelementptr inbounds i32, ptr addrspace(1) undef, i64 %10
61-
%12 = ashr i32 undef, %4
60+
%11 = getelementptr inbounds i32, ptr addrspace(1) %p, i64 %10
61+
%12 = ashr i32 12, %4
6262
store i32 %12, ptr addrspace(1) %11, align 4
6363
%13 = add i32 %7, 1
6464
%14 = icmp sgt i32 %13, 61
@@ -74,7 +74,7 @@ define void @test_01(i1 %arg) {
7474
; CHECK: store <4 x i32>
7575

7676
; Function Attrs: uwtable
77-
define void @test_02(i1 %arg) {
77+
define void @test_02(ptr addrspace(1) %p, i1 %arg) {
7878
br label %.outer
7979

8080
; <label>:1: ; preds = %2
@@ -96,8 +96,8 @@ define void @test_02(i1 %arg) {
9696
%8 = phi i32 [ %.ph2, %.outer ], [ %7, %6 ]
9797
%9 = add i32 %8, 2
9898
%10 = zext i32 %9 to i64
99-
%11 = getelementptr inbounds i32, ptr addrspace(1) undef, i64 %10
100-
%12 = ashr i32 undef, %4
99+
%11 = getelementptr inbounds i32, ptr addrspace(1) %p, i64 %10
100+
%12 = ashr i32 12, %4
101101
store i32 %12, ptr addrspace(1) %11, align 4
102102
%13 = add i32 %7, 1
103103
%14 = icmp sgt i32 %13, 610

llvm/test/Transforms/LoopVectorize/X86/cost-model-assert.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1212
target triple = "x86_64-w64-windows-gnu"
1313

14-
define void @cff_index_load_offsets(i1 %cond, i8 %x, ptr %p) #0 {
14+
define void @cff_index_load_offsets(i1 %cond, i8 %x, ptr %p, ptr %pend) #0 {
1515
; CHECK-LABEL: define void @cff_index_load_offsets(
16-
; CHECK-SAME: i1 [[COND:%.*]], i8 [[X:%.*]], ptr [[P:%.*]]) #[[ATTR0:[0-9]+]] {
16+
; CHECK-SAME: i1 [[COND:%.*]], i8 [[X:%.*]], ptr [[P:%.*]], ptr [[PEND:%.*]]) #[[ATTR0:[0-9]+]] {
1717
; CHECK-NEXT: [[ENTRY:.*:]]
1818
; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[EXIT:.*]]
1919
; CHECK: [[IF_THEN]]:
@@ -26,14 +26,14 @@ define void @cff_index_load_offsets(i1 %cond, i8 %x, ptr %p) #0 {
2626
; CHECK-NEXT: [[CONV73:%.*]] = zext i8 [[TMP0]] to i32
2727
; CHECK-NEXT: [[SHL74:%.*]] = shl nuw nsw i32 [[CONV73]], 16
2828
; CHECK-NEXT: [[OR75:%.*]] = or i32 [[SHL74]], [[SHL71]]
29-
; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr undef, align 1, !tbaa [[CHAR_TBAA1]]
30-
; CHECK-NEXT: [[SHL78:%.*]] = shl nuw nsw i32 undef, 8
29+
; CHECK-NEXT: [[TMP1:%.*]] = load i8, ptr [[P]], align 1, !tbaa [[CHAR_TBAA1]]
30+
; CHECK-NEXT: [[SHL78:%.*]] = shl nuw nsw i32 12, 8
3131
; CHECK-NEXT: [[OR79:%.*]] = or i32 [[OR75]], [[SHL78]]
3232
; CHECK-NEXT: [[CONV81:%.*]] = zext i8 [[TMP1]] to i32
3333
; CHECK-NEXT: [[OR83:%.*]] = or i32 [[OR79]], [[CONV81]]
34-
; CHECK-NEXT: store i32 [[OR83]], ptr undef, align 4, !tbaa [[LONG_TBAA4:![0-9]+]]
34+
; CHECK-NEXT: store i32 [[OR83]], ptr [[P]], align 4, !tbaa [[LONG_TBAA4:![0-9]+]]
3535
; CHECK-NEXT: [[ADD_PTR86]] = getelementptr inbounds i8, ptr [[P_359]], i64 4
36-
; CHECK-NEXT: [[CMP66:%.*]] = icmp ult ptr [[ADD_PTR86]], undef
36+
; CHECK-NEXT: [[CMP66:%.*]] = icmp ult ptr [[ADD_PTR86]], [[PEND]]
3737
; CHECK-NEXT: br i1 [[CMP66]], label %[[FOR_BODY68]], label %[[SW_EPILOG:.*]]
3838
; CHECK: [[SW_EPILOG]]:
3939
; CHECK-NEXT: unreachable
@@ -54,14 +54,14 @@ for.body68: ; preds = %for.body68, %if.the
5454
%conv73 = zext i8 %0 to i32
5555
%shl74 = shl nuw nsw i32 %conv73, 16
5656
%or75 = or i32 %shl74, %shl71
57-
%1 = load i8, ptr undef, align 1, !tbaa !1
58-
%shl78 = shl nuw nsw i32 undef, 8
57+
%1 = load i8, ptr %p, align 1, !tbaa !1
58+
%shl78 = shl nuw nsw i32 12, 8
5959
%or79 = or i32 %or75, %shl78
6060
%conv81 = zext i8 %1 to i32
6161
%or83 = or i32 %or79, %conv81
62-
store i32 %or83, ptr undef, align 4, !tbaa !4
62+
store i32 %or83, ptr %p, align 4, !tbaa !4
6363
%add.ptr86 = getelementptr inbounds i8, ptr %p.359, i64 4
64-
%cmp66 = icmp ult ptr %add.ptr86, undef
64+
%cmp66 = icmp ult ptr %add.ptr86, %pend
6565
br i1 %cmp66, label %for.body68, label %sw.epilog
6666

6767
sw.epilog: ; preds = %for.body68

llvm/test/Transforms/LoopVectorize/X86/interleaved-accesses-large-gap.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ for.cond.cleanup: ; preds = %for.body
4141

4242
; Make sure interleave groups with a key being the special 'empty' value for
4343
; the map do not cause a crash.
44-
define void @test_gap_empty_key() {
45-
; CHECK-LABEL: @test_gap_empty_key()
44+
define void @test_gap_empty_key(ptr %p) {
45+
; CHECK-LABEL: @test_gap_empty_key(ptr %p)
4646
; CHECK-NEXT: entry:
4747
; CHECK-NEXT: br label %for.body
4848

@@ -57,7 +57,7 @@ entry:
5757
for.body:
5858
%iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ]
5959
%iv.next = add nsw i64 %iv, 1
60-
%arrayidx = getelementptr inbounds [3 x i32], ptr undef, i64 0, i64 %iv.next
60+
%arrayidx = getelementptr inbounds [3 x i32], ptr %p, i64 0, i64 %iv.next
6161
%G2 = getelementptr i32, ptr %arrayidx, i64 %iv.next
6262
%G9 = getelementptr i32, ptr %G2, i32 -2147483647
6363
store i32 0, ptr %G2
@@ -71,8 +71,8 @@ exit:
7171

7272
; Make sure interleave groups with a key being the special 'tombstone' value for
7373
; the map do not cause a crash.
74-
define void @test_tombstone_key() {
75-
; CHECK-LABEL: @test_tombstone_key()
74+
define void @test_tombstone_key(ptr %p) {
75+
; CHECK-LABEL: @test_tombstone_key(ptr %p)
7676
; CHECK-NEXT: entry:
7777
; CHECK-NEXT: br label %for.body
7878

@@ -87,7 +87,7 @@ entry:
8787
for.body:
8888
%iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ]
8989
%iv.next = add nsw i64 %iv, 1
90-
%arrayidx = getelementptr inbounds [3 x i32], ptr undef, i64 0, i64 %iv.next
90+
%arrayidx = getelementptr inbounds [3 x i32], ptr %p, i64 0, i64 %iv.next
9191
%G2 = getelementptr i32, ptr %arrayidx, i64 %iv.next
9292
%G9 = getelementptr i32, ptr %G2, i32 -2147483648
9393
store i32 0, ptr %G2

llvm/test/Transforms/LoopVectorize/demanded-bits-of-pointer-instruction.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
; Only make sure we do not crash.
55

66
; CHECK: @test
7-
define void @test(ptr %ptr, ptr %ptr_end) {
7+
define void @test(i8 %v, ptr %ptr, ptr %ptr_end) {
88
start:
99
br label %loop
1010

1111
loop:
1212
%ptr2 = phi ptr [ %ptr3, %loop ], [ %ptr, %start ]
13-
%x = sext i8 undef to i64
13+
%x = sext i8 %v to i64
1414
%ptr3 = getelementptr inbounds i8, ptr %ptr2, i64 1
1515
%cmp = icmp ult ptr %ptr3, %ptr_end
1616
br i1 %cmp, label %loop, label %end

llvm/test/Transforms/LoopVectorize/if-pred-stores.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,15 @@ for.inc26:
384384
; conditional store to remain scalar. Since we can only type-shrink vector
385385
; types, we shouldn't try to represent the expression in a smaller type.
386386
;
387-
define void @minimal_bit_widths(i1 %c) {
387+
define void @minimal_bit_widths(ptr %p, i1 %c) {
388388
; UNROLL-LABEL: @minimal_bit_widths(
389389
; UNROLL-NEXT: entry:
390390
; UNROLL-NEXT: br label [[VECTOR_BODY:%.*]]
391391
; UNROLL: vector.body:
392392
; UNROLL-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ]
393393
; UNROLL-NEXT: [[TMP1:%.*]] = add i64 [[INDEX]], 1
394-
; UNROLL-NEXT: [[TMP2:%.*]] = getelementptr i8, ptr undef, i64 [[INDEX]]
395-
; UNROLL-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr undef, i64 [[TMP1]]
394+
; UNROLL-NEXT: [[TMP2:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[INDEX]]
395+
; UNROLL-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr [[P]], i64 [[TMP1]]
396396
; UNROLL-NEXT: [[TMP4:%.*]] = load i8, ptr [[TMP2]], align 1
397397
; UNROLL-NEXT: [[TMP5:%.*]] = load i8, ptr [[TMP3]], align 1
398398
; UNROLL-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE2]]
@@ -415,8 +415,8 @@ define void @minimal_bit_widths(i1 %c) {
415415
; UNROLL-NOSIMPLIFY: vector.body:
416416
; UNROLL-NOSIMPLIFY-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ]
417417
; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = add i64 [[INDEX]], 1
418-
; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = getelementptr i8, ptr undef, i64 [[INDEX]]
419-
; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr undef, i64 [[TMP1]]
418+
; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[INDEX]]
419+
; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr [[P]], i64 [[TMP1]]
420420
; UNROLL-NOSIMPLIFY-NEXT: [[TMP4:%.*]] = load i8, ptr [[TMP2]], align 1
421421
; UNROLL-NOSIMPLIFY-NEXT: [[TMP5:%.*]] = load i8, ptr [[TMP3]], align 1
422422
; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]]
@@ -442,16 +442,16 @@ define void @minimal_bit_widths(i1 %c) {
442442
; VEC-NEXT: br label [[VECTOR_BODY:%.*]]
443443
; VEC: vector.body:
444444
; VEC-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ]
445-
; VEC-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr undef, i64 [[INDEX]]
445+
; VEC-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[INDEX]]
446446
; VEC-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i8>, ptr [[TMP1]], align 1
447447
; VEC-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE2]]
448448
; VEC: pred.store.if:
449449
; VEC-NEXT: [[TMP8:%.*]] = add i64 [[INDEX]], 0
450-
; VEC-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr undef, i64 [[TMP8]]
450+
; VEC-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr [[P]], i64 [[TMP8]]
451451
; VEC-NEXT: [[TMP4:%.*]] = extractelement <2 x i8> [[WIDE_LOAD]], i32 0
452452
; VEC-NEXT: store i8 [[TMP4]], ptr [[TMP3]], align 1
453453
; VEC-NEXT: [[TMP5:%.*]] = add i64 [[INDEX]], 1
454-
; VEC-NEXT: [[TMP6:%.*]] = getelementptr i8, ptr undef, i64 [[TMP5]]
454+
; VEC-NEXT: [[TMP6:%.*]] = getelementptr i8, ptr [[P]], i64 [[TMP5]]
455455
; VEC-NEXT: [[TMP7:%.*]] = extractelement <2 x i8> [[WIDE_LOAD]], i32 1
456456
; VEC-NEXT: store i8 [[TMP7]], ptr [[TMP6]], align 1
457457
; VEC-NEXT: br label [[PRED_STORE_CONTINUE2]]
@@ -468,7 +468,7 @@ entry:
468468
for.body:
469469
%tmp0 = phi i64 [ %tmp6, %for.inc ], [ 0, %entry ]
470470
%tmp1 = phi i64 [ %tmp7, %for.inc ], [ 1000, %entry ]
471-
%tmp2 = getelementptr i8, ptr undef, i64 %tmp0
471+
%tmp2 = getelementptr i8, ptr %p, i64 %tmp0
472472
%tmp3 = load i8, ptr %tmp2, align 1
473473
br i1 %c, label %if.then, label %for.inc
474474

llvm/test/Transforms/LoopVectorize/nsw-crash.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
target datalayout =
44
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
55

6-
define void @test(i1 %arg) {
6+
define void @test(ptr %p, i1 %arg) {
77
entry:
88
br i1 %arg, label %while.end, label %while.body.lr.ph
99

1010
while.body.lr.ph:
1111
br label %while.body
1212

1313
while.body:
14-
%it.sroa.0.091 = phi ptr [ undef, %while.body.lr.ph ], [ %incdec.ptr.i, %while.body ]
14+
%it.sroa.0.091 = phi ptr [ %p, %while.body.lr.ph ], [ %incdec.ptr.i, %while.body ]
1515
%incdec.ptr.i = getelementptr inbounds i32, ptr %it.sroa.0.091, i64 1
1616
%inc32 = add i32 undef, 1 ; <------------- Make sure we don't set NSW flags to the undef.
1717
%cmp.i11 = icmp eq ptr %incdec.ptr.i, undef

0 commit comments

Comments
 (0)