Skip to content

Commit c876761

Browse files
committed
[IndVars] Add test for #102597 (NFC)
1 parent 895ca18 commit c876761

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes=indvars < %s | FileCheck %s
3+
4+
; FIXME: This is a miscompile.
5+
define void @test() {
6+
; CHECK-LABEL: define void @test() {
7+
; CHECK-NEXT: [[ENTRY:.*]]:
8+
; CHECK-NEXT: br label %[[LOOP:.*]]
9+
; CHECK: [[LOOP]]:
10+
; CHECK-NEXT: [[IV:%.*]] = phi i128 [ 3, %[[ENTRY]] ], [ [[IV_DEC:%.*]], %[[LOOP_LATCH:.*]] ]
11+
; CHECK-NEXT: br i1 true, label %[[LOOP_LATCH]], label %[[IF:.*]]
12+
; CHECK: [[IF]]:
13+
; CHECK-NEXT: call void @foo()
14+
; CHECK-NEXT: br label %[[LOOP_LATCH]]
15+
; CHECK: [[LOOP_LATCH]]:
16+
; CHECK-NEXT: [[IV_DEC]] = add nsw i128 [[IV]], -1
17+
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i128 [[IV]], 0
18+
; CHECK-NEXT: br i1 [[CMP]], label %[[LOOP]], label %[[EXIT:.*]]
19+
; CHECK: [[EXIT]]:
20+
; CHECK-NEXT: ret void
21+
;
22+
entry:
23+
br label %loop
24+
25+
loop:
26+
%iv = phi i128 [ 3, %entry ], [ %iv.dec, %loop.latch ]
27+
%tobool = icmp ne i128 %iv, 0
28+
br i1 %tobool, label %loop.latch, label %if
29+
30+
if:
31+
call void @foo()
32+
br label %loop.latch
33+
34+
loop.latch:
35+
%iv.dec = add nsw i128 %iv, -1
36+
%cmp = icmp sgt i128 %iv, 0
37+
br i1 %cmp, label %loop, label %exit
38+
39+
exit:
40+
ret void
41+
}
42+
43+
declare void @foo()

0 commit comments

Comments
 (0)