blob: aedd6f23091c92d01ab8f3593b982521b7902d8b [file] [log] [blame]
Andrew Trick5b28cc82011-09-13 03:17:25 +00001; The loop canonicalization pass should guarantee that there is one backedge
2; for all loops. This allows the -indvars pass to recognize the %IV
Chris Lattner3e537002003-10-12 22:26:42 +00003; induction variable in this testcase.
4
Andrew Trick5b28cc82011-09-13 03:17:25 +00005; RUN: opt < %s -indvars -S | FileCheck %s
6; CHECK: Loop.backedge:
7; CHECK-NOT: br
8; CHECK: br label %Loop
Chris Lattner3e537002003-10-12 22:26:42 +00009
Tanya Lattner8bf97c22008-03-25 04:26:08 +000010define i32 @test(i1 %C) {
11; <label>:0
Chris Lattner3e537002003-10-12 22:26:42 +000012 br label %Loop
Tanya Lattner8bf97c22008-03-25 04:26:08 +000013Loop: ; preds = %BE2, %BE1, %0
Dan Gohmaned7f3a02009-04-28 22:05:13 +000014 %IV = phi i32 [ 1, %0 ], [ %IV2, %BE1 ], [ %IV2, %BE2 ] ; <i32> [#uses=2]
15 store i32 %IV, i32* null
Tanya Lattner8bf97c22008-03-25 04:26:08 +000016 %IV2 = add i32 %IV, 2 ; <i32> [#uses=2]
17 br i1 %C, label %BE1, label %BE2
18BE1: ; preds = %Loop
Chris Lattner3e537002003-10-12 22:26:42 +000019 br label %Loop
Tanya Lattner8bf97c22008-03-25 04:26:08 +000020BE2: ; preds = %Loop
Chris Lattner3e537002003-10-12 22:26:42 +000021 br label %Loop
22}
Tanya Lattner8bf97c22008-03-25 04:26:08 +000023