Skip to content

Commit 93530e7

Browse files
committed
IndVarSimplify/test: add idx.start argument
1 parent 9c63c07 commit 93530e7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,33 @@
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"
99

10-
define void @hoge(i64 %x, ptr %ptr) {
10+
define void @hoge(i64 %x, i64 %idx.start, ptr %ptr) {
1111
; CHECK-LABEL: @hoge(
1212
; CHECK-NEXT: entry:
1313
; CHECK-NEXT: [[N:%.*]] = sdiv exact i64 [[X:%.*]], 40
14+
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[IDX_START:%.*]], 1
15+
; CHECK-NEXT: [[TMP1:%.*]] = sub i64 [[TMP0]], [[N]]
1416
; CHECK-NEXT: br label [[HEADER:%.*]]
1517
; CHECK: header:
16-
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT2:%.*]], [[LATCH:%.*]] ], [ 1, [[ENTRY:%.*]] ]
17-
; CHECK-NEXT: [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH]] ], [ 0, [[ENTRY]] ]
18+
; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LATCH:%.*]] ], [ [[TMP1]], [[ENTRY:%.*]] ]
19+
; CHECK-NEXT: [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH]] ], [ [[IDX_START]], [[ENTRY]] ]
1820
; CHECK-NEXT: [[COND:%.*]] = icmp sgt i64 [[N]], [[IDX]]
1921
; CHECK-NEXT: br i1 [[COND]], label [[END:%.*]], label [[INNER_PREHEADER:%.*]]
2022
; CHECK: inner.preheader:
2123
; CHECK-NEXT: br label [[INNER:%.*]]
2224
; CHECK: inner:
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: [[I:%.*]] = phi i64 [ [[I_NEXT:%.*]], [[INNER]] ], [ 0, [[INNER_PREHEADER]] ]
26+
; CHECK-NEXT: [[I_NEXT]] = add nuw i64 [[I]], 1
2527
; CHECK-NEXT: store i64 0, ptr [[PTR:%.*]], align 8
2628
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[I_NEXT]], [[INDVARS_IV]]
2729
; CHECK-NEXT: br i1 [[EXITCOND]], label [[INNER]], label [[INNER_EXIT:%.*]]
2830
; CHECK: inner_exit:
31+
; CHECK-NEXT: [[INDVAR:%.*]] = phi i64 [ [[I_NEXT]], [[INNER]] ]
32+
; CHECK-NEXT: [[INDVAR_USE:%.*]] = add i64 [[INDVAR]], 1
2933
; CHECK-NEXT: br label [[LATCH]]
3034
; CHECK: latch:
3135
; CHECK-NEXT: [[IDX_NEXT]] = add nsw i64 [[IDX]], -1
32-
; CHECK-NEXT: [[INDVARS_IV_NEXT2]] = add nsw i64 [[INDVARS_IV]], -1
36+
; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], -1
3337
; CHECK-NEXT: br label [[HEADER]]
3438
; CHECK: end:
3539
; CHECK-NEXT: ret void
@@ -39,7 +43,7 @@ entry: ; preds = %entry
3943
br label %header
4044

4145
header: ; preds = %latch, %entry
42-
%idx = phi i64 [ %idx.next, %latch ], [ 0, %entry ]
46+
%idx = phi i64 [ %idx.next, %latch ], [ %idx.start, %entry ]
4347
%cond = icmp sgt i64 %n, %idx
4448
br i1 %cond, label %end, label %inner
4549

0 commit comments

Comments
 (0)