Skip to content

Commit 866ac9a

Browse files
authored
[LV] Address postcommit review for PR84782 (llvm#84797)
This testcase was added to show miscompile in llvm#81872
1 parent 36a2752 commit 866ac9a

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

llvm/test/Transforms/LoopVectorize/X86/pr81872.ll

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
44
target triple = "x86_64-unknown-linux-gnu"
55

6-
@global = external global ptr addrspace(1), align 8
7-
86
; PR 81872 explains the issue.
97

108
; If we vectorize, we have a miscompile where array IV and thereby value stored in (arr[99],
119
; arr[98]) is calculated incorrectly since disjoint or was only disjoint because
1210
; of dominating conditions. Dropping the disjoint to avoid poison still changes
1311
; the behaviour since now the or is no longer equivalent to the add.
14-
; Function Attrs: uwtable
12+
;
1513
define void @test(ptr noundef align 8 dereferenceable_or_null(16) %arr) #0 {
1614
; CHECK-LABEL: define void @test(
1715
; 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 {
4543
; CHECK-NEXT: br i1 true, label [[BB6:%.*]], label [[SCALAR_PH]]
4644
; CHECK: scalar.ph:
4745
; 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:%.*]] ]
5149
; CHECK-NEXT: [[AND:%.*]] = and i64 [[IV]], 1
5250
; 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]+]]
5452
; CHECK: bb18:
5553
; CHECK-NEXT: [[OR:%.*]] = or disjoint i64 [[IV]], 1
5654
; CHECK-NEXT: [[GETELEMENTPTR19:%.*]] = getelementptr inbounds i64, ptr [[ARR]], i64 [[OR]]
5755
; 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:
6058
; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], -1
6159
; 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]+]]
6361
; CHECK: bb6:
6462
; CHECK-NEXT: ret void
6563
;
6664
bb5:
67-
br label %bb15
65+
br label %loop.header
6866

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 ]
7169
%and = and i64 %iv, 1
7270
%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
7472

75-
bb18: ; preds = %bb15
73+
bb18: ; preds = %loop.header
7674
%or = or disjoint i64 %iv, 1
7775
%getelementptr19 = getelementptr inbounds i64, ptr %arr, i64 %or
7876
store i64 1, ptr %getelementptr19, align 8
79-
br label %bb20
77+
br label %loop.latch
8078

81-
bb20: ; preds = %bb18, %bb15
79+
loop.latch: ; preds = %bb18, %loop.header
8280
%iv.next = add nsw i64 %iv, -1
8381
%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
8583

8684
bb6:
8785
ret void

0 commit comments

Comments
 (0)