• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -indvars -S | FileCheck %s
2;
3; Make sure IndVars preserves LCSSA form, especially across loop nests.
4
5target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
6
7define void @PR18642(i32 %x) {
8; CHECK-LABEL: @PR18642(
9entry:
10  br label %outer.header
11; CHECK:   br label %outer.header
12
13outer.header:
14; CHECK: outer.header:
15  %outer.iv = phi i32 [ 0, %entry ], [ %x, %outer.latch ]
16  br label %inner.header
17; CHECK:   %[[SCEV_EXPANDED:.*]] = add i32
18; CHECK:   br label %inner.header
19
20inner.header:
21; CHECK: inner.header:
22  %inner.iv = phi i32 [ undef, %outer.header ], [ %inc, %inner.latch ]
23  %cmp1 = icmp slt i32 %inner.iv, %outer.iv
24  br i1 %cmp1, label %inner.latch, label %outer.latch
25; CHECK:   br i1 {{.*}}, label %inner.latch, label %outer.latch
26
27inner.latch:
28; CHECK: inner.latch:
29  %inc = add nsw i32 %inner.iv, 1
30  %cmp2 = icmp slt i32 %inner.iv, %outer.iv
31  br i1 %cmp2, label %inner.header, label %exit
32; CHECK:   br i1 {{.*}}, label %inner.header, label %[[EXIT_FROM_INNER:.*]]
33
34outer.latch:
35; CHECK: outer.latch:
36  br i1 undef, label %outer.header, label %exit
37; CHECK:   br i1 {{.*}}, label %outer.header, label %[[EXIT_FROM_OUTER:.*]]
38
39; CHECK: [[EXIT_FROM_INNER]]:
40; CHECK-NEXT: %[[LCSSA:.*]] = phi i32 [ %[[SCEV_EXPANDED]], %inner.latch ]
41; CHECK-NEXT: br label %exit
42
43; CHECK: [[EXIT_FROM_OUTER]]:
44; CHECK-NEXT: br label %exit
45
46exit:
47; CHECK: exit:
48  %exit.phi = phi i32 [ %inc, %inner.latch ], [ undef, %outer.latch ]
49; CHECK-NEXT: phi i32 [ %[[LCSSA]], %[[EXIT_FROM_INNER]] ], [ undef, %[[EXIT_FROM_OUTER]] ]
50  ret void
51}
52