Skip to content

Commit 9c63c07

Browse files
committed
IndVarSimplify/test: improve test
1 parent 6a8e512 commit 9c63c07

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-values-phi.ll

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,40 @@
66
; status. This was caught by the expensive check introduced in D86589.
77

88
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9-
target triple = "x86_64-unknown-linux-gnu"
109

11-
@ptr = external global i64
12-
13-
define dso_local void @hoge() local_unnamed_addr {
10+
define void @hoge(i64 %x, ptr %ptr) {
1411
; CHECK-LABEL: @hoge(
1512
; CHECK-NEXT: entry:
16-
; CHECK-NEXT: [[N:%.*]] = sdiv exact i64 poison, 40
17-
; CHECK-NEXT: [[TMP0:%.*]] = sub i64 poison, [[N]]
13+
; CHECK-NEXT: [[N:%.*]] = sdiv exact i64 [[X:%.*]], 40
1814
; CHECK-NEXT: br label [[HEADER:%.*]]
1915
; CHECK: header:
20-
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LATCH:%.*]] ], [ [[TMP0]], [[ENTRY:%.*]] ]
21-
; CHECK-NEXT: [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH]] ], [ poison, [[ENTRY]] ]
16+
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT2:%.*]], [[LATCH:%.*]] ], [ 1, [[ENTRY:%.*]] ]
17+
; CHECK-NEXT: [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH]] ], [ 0, [[ENTRY]] ]
2218
; CHECK-NEXT: [[COND:%.*]] = icmp sgt i64 [[N]], [[IDX]]
2319
; CHECK-NEXT: br i1 [[COND]], label [[END:%.*]], label [[INNER_PREHEADER:%.*]]
2420
; CHECK: inner.preheader:
2521
; CHECK-NEXT: br label [[INNER:%.*]]
2622
; CHECK: inner:
27-
; CHECK-NEXT: [[I:%.*]] = phi i64 [ [[I_NEXT:%.*]], [[INNER]] ], [ 0, [[INNER_PREHEADER]] ]
28-
; CHECK-NEXT: [[I_NEXT]] = add nuw i64 [[I]], 1
29-
; CHECK-NEXT: store i64 poison, ptr @ptr, align 8
23+
; CHECK-NEXT: [[J:%.*]] = phi i64 [ [[I_NEXT:%.*]], [[INNER]] ], [ [[N]], [[INNER_PREHEADER]] ]
24+
; CHECK-NEXT: [[I_NEXT]] = add nsw i64 [[J]], 1
25+
; CHECK-NEXT: store i64 0, ptr [[PTR:%.*]], align 8
3026
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[I_NEXT]], [[INDVARS_IV]]
3127
; CHECK-NEXT: br i1 [[EXITCOND]], label [[INNER]], label [[INNER_EXIT:%.*]]
3228
; CHECK: inner_exit:
33-
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[I_NEXT]], [[INNER]] ]
34-
; CHECK-NEXT: [[INDVAR_USE:%.*]] = add i64 [[INDVAR]], 1
3529
; CHECK-NEXT: br label [[LATCH]]
3630
; CHECK: latch:
3731
; CHECK-NEXT: [[IDX_NEXT]] = add nsw i64 [[IDX]], -1
38-
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], -1
32+
; CHECK-NEXT: [[INDVARS_IV_NEXT2]] = add nsw i64 [[INDVARS_IV]], -1
3933
; CHECK-NEXT: br label [[HEADER]]
4034
; CHECK: end:
4135
; CHECK-NEXT: ret void
4236
;
4337
entry: ; preds = %entry
44-
%n = sdiv exact i64 poison, 40
38+
%n = sdiv exact i64 %x, 40
4539
br label %header
4640

4741
header: ; preds = %latch, %entry
48-
%idx = phi i64 [ %idx.next, %latch ], [ poison, %entry ]
42+
%idx = phi i64 [ %idx.next, %latch ], [ 0, %entry ]
4943
%cond = icmp sgt i64 %n, %idx
5044
br i1 %cond, label %end, label %inner
5145

@@ -54,7 +48,7 @@ inner: ; preds = %inner, %header
5448
%j = phi i64 [ %j.next, %inner ], [ %n, %header ]
5549
%i.next = add nsw i64 %i, 1
5650
%j.next = add nsw i64 %j, 1
57-
store i64 poison, ptr @ptr
51+
store i64 0, ptr %ptr
5852
%cond1 = icmp slt i64 %j, %idx
5953
br i1 %cond1, label %inner, label %inner_exit
6054

0 commit comments

Comments
 (0)