|
3 | 3 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
4 | 4 | target triple = "x86_64-unknown-linux-gnu"
|
5 | 5 |
|
6 |
| -@global = external global ptr addrspace(1), align 8 |
7 |
| - |
8 | 6 | ; PR 81872 explains the issue.
|
9 | 7 |
|
10 | 8 | ; If we vectorize, we have a miscompile where array IV and thereby value stored in (arr[99],
|
11 | 9 | ; arr[98]) is calculated incorrectly since disjoint or was only disjoint because
|
12 | 10 | ; of dominating conditions. Dropping the disjoint to avoid poison still changes
|
13 | 11 | ; the behaviour since now the or is no longer equivalent to the add.
|
14 |
| -; Function Attrs: uwtable |
| 12 | +; |
15 | 13 | define void @test(ptr noundef align 8 dereferenceable_or_null(16) %arr) #0 {
|
16 | 14 | ; CHECK-LABEL: define void @test(
|
17 | 15 | ; CHECK-SAME: ptr noundef align 8 dereferenceable_or_null(16) [[ARR:%.*]]) #[[ATTR0:[0-9]+]] {
|
@@ -45,43 +43,43 @@ define void @test(ptr noundef align 8 dereferenceable_or_null(16) %arr) #0 {
|
45 | 43 | ; CHECK-NEXT: br i1 true, label [[BB6:%.*]], label [[SCALAR_PH]]
|
46 | 44 | ; CHECK: scalar.ph:
|
47 | 45 | ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 87, [[MIDDLE_BLOCK]] ], [ 99, [[BB5:%.*]] ]
|
48 |
| -; CHECK-NEXT: br label [[BB15:%.*]] |
49 |
| -; CHECK: bb15: |
50 |
| -; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[BB20:%.*]] ] |
| 46 | +; CHECK-NEXT: br label [[LOOP_HEADER:%.*]] |
| 47 | +; CHECK: loop.header: |
| 48 | +; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ] |
51 | 49 | ; CHECK-NEXT: [[AND:%.*]] = and i64 [[IV]], 1
|
52 | 50 | ; CHECK-NEXT: [[ICMP17:%.*]] = icmp eq i64 [[AND]], 0
|
53 |
| -; CHECK-NEXT: br i1 [[ICMP17]], label [[BB18:%.*]], label [[BB20]], !prof [[PROF5:![0-9]+]] |
| 51 | +; CHECK-NEXT: br i1 [[ICMP17]], label [[BB18:%.*]], label [[LOOP_LATCH]], !prof [[PROF5:![0-9]+]] |
54 | 52 | ; CHECK: bb18:
|
55 | 53 | ; CHECK-NEXT: [[OR:%.*]] = or disjoint i64 [[IV]], 1
|
56 | 54 | ; CHECK-NEXT: [[GETELEMENTPTR19:%.*]] = getelementptr inbounds i64, ptr [[ARR]], i64 [[OR]]
|
57 | 55 | ; CHECK-NEXT: store i64 1, ptr [[GETELEMENTPTR19]], align 8
|
58 |
| -; CHECK-NEXT: br label [[BB20]] |
59 |
| -; CHECK: bb20: |
| 56 | +; CHECK-NEXT: br label [[LOOP_LATCH]] |
| 57 | +; CHECK: loop.latch: |
60 | 58 | ; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], -1
|
61 | 59 | ; CHECK-NEXT: [[ICMP22:%.*]] = icmp eq i64 [[IV_NEXT]], 90
|
62 |
| -; CHECK-NEXT: br i1 [[ICMP22]], label [[BB6]], label [[BB15]], !prof [[PROF6:![0-9]+]], !llvm.loop [[LOOP7:![0-9]+]] |
| 60 | +; CHECK-NEXT: br i1 [[ICMP22]], label [[BB6]], label [[LOOP_HEADER]], !prof [[PROF6:![0-9]+]], !llvm.loop [[LOOP7:![0-9]+]] |
63 | 61 | ; CHECK: bb6:
|
64 | 62 | ; CHECK-NEXT: ret void
|
65 | 63 | ;
|
66 | 64 | bb5:
|
67 |
| - br label %bb15 |
| 65 | + br label %loop.header |
68 | 66 |
|
69 |
| -bb15: ; preds = %bb20, %bb8 |
70 |
| - %iv = phi i64 [ 99, %bb5 ], [ %iv.next, %bb20 ] |
| 67 | +loop.header: ; preds = %loop.latch, %bb8 |
| 68 | + %iv = phi i64 [ 99, %bb5 ], [ %iv.next, %loop.latch ] |
71 | 69 | %and = and i64 %iv, 1
|
72 | 70 | %icmp17 = icmp eq i64 %and, 0
|
73 |
| - br i1 %icmp17, label %bb18, label %bb20, !prof !21 |
| 71 | + br i1 %icmp17, label %bb18, label %loop.latch, !prof !21 |
74 | 72 |
|
75 |
| -bb18: ; preds = %bb15 |
| 73 | +bb18: ; preds = %loop.header |
76 | 74 | %or = or disjoint i64 %iv, 1
|
77 | 75 | %getelementptr19 = getelementptr inbounds i64, ptr %arr, i64 %or
|
78 | 76 | store i64 1, ptr %getelementptr19, align 8
|
79 |
| - br label %bb20 |
| 77 | + br label %loop.latch |
80 | 78 |
|
81 |
| -bb20: ; preds = %bb18, %bb15 |
| 79 | +loop.latch: ; preds = %bb18, %loop.header |
82 | 80 | %iv.next = add nsw i64 %iv, -1
|
83 | 81 | %icmp22 = icmp eq i64 %iv.next, 90
|
84 |
| - br i1 %icmp22, label %bb6, label %bb15, !prof !22 |
| 82 | + br i1 %icmp22, label %bb6, label %loop.header, !prof !22 |
85 | 83 |
|
86 | 84 | bb6:
|
87 | 85 | ret void
|
|
0 commit comments