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