1 ; RUN: opt -indvars -S < %s | FileCheck %s
8 define i32 @test_nested2(i32 %tnr) {
9 ; CHECK-LABEL: test_nested2
10 ; CHECK-NOT: %indvars.iv
13 ; indvars should not replace the i.0 variable with a new one; SCEVExpander
14 ; should determine that the old one is good to reuse.
17 %res = alloca i32, align 4
18 store volatile i32 0, i32* %res, align 4
19 %call = call i32 @fn()
22 for.cond: ; preds = %for.inc6, %entry
23 %i.0 = phi i32 [ 0, %entry ], [ %inc7, %for.inc6 ]
24 %cmp = icmp slt i32 %i.0, %call
25 br i1 %cmp, label %for.body, label %for.cond.cleanup
27 for.cond.cleanup: ; preds = %for.cond
30 for.body: ; preds = %for.cond
33 for.cond1: ; preds = %for.inc, %for.body
34 %j.0 = phi i32 [ 0, %for.body ], [ %inc5, %for.inc ]
35 %cmp2 = icmp slt i32 %j.0, %i.0
36 br i1 %cmp2, label %for.body4, label %for.cond.cleanup3
38 for.cond.cleanup3: ; preds = %for.cond1
41 for.body4: ; preds = %for.cond1
42 %0 = load volatile i32, i32* %res, align 4
43 %inc = add nsw i32 %0, 1
44 store volatile i32 %inc, i32* %res, align 4
47 for.inc: ; preds = %for.body4
48 %inc5 = add nsw i32 %j.0, 1
51 for.end: ; preds = %for.cond.cleanup3
54 for.inc6: ; preds = %for.end
55 %inc7 = add nsw i32 %i.0, 1
58 for.end8: ; preds = %for.cond.cleanup
59 %1 = load volatile i32, i32* %res, align 4
60 %cmp9 = icmp eq i32 %1, 45
61 %conv = zext i1 %cmp9 to i32