1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -replexitval=always -S | FileCheck %s
3 ; Make sure IndVars preserves LCSSA form, especially across loop nests.
5 target 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"
7 define void @PR18642(i32 %x) {
8 ; CHECK-LABEL: @PR18642(
10 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
11 ; CHECK: outer.header:
12 ; CHECK-NEXT: br label [[INNER_HEADER:%.*]]
13 ; CHECK: inner.header:
14 ; CHECK-NEXT: br i1 false, label [[INNER_LATCH:%.*]], label [[OUTER_LATCH:%.*]]
16 ; CHECK-NEXT: br i1 true, label [[INNER_HEADER]], label [[EXIT_LOOPEXIT:%.*]]
18 ; CHECK-NEXT: br i1 false, label [[OUTER_HEADER]], label [[EXIT_LOOPEXIT1:%.*]]
19 ; CHECK: exit.loopexit:
20 ; CHECK-NEXT: br label [[EXIT:%.*]]
21 ; CHECK: exit.loopexit1:
22 ; CHECK-NEXT: br label [[EXIT]]
24 ; CHECK-NEXT: ret void
27 br label %outer.header
30 %outer.iv = phi i32 [ 0, %entry ], [ %x, %outer.latch ]
31 br label %inner.header
34 %inner.iv = phi i32 [ undef, %outer.header ], [ %inc, %inner.latch ]
35 %cmp1 = icmp slt i32 %inner.iv, %outer.iv
36 br i1 %cmp1, label %inner.latch, label %outer.latch
39 %inc = add nsw i32 %inner.iv, 1
40 %cmp2 = icmp slt i32 %inner.iv, %outer.iv
41 br i1 %cmp2, label %inner.header, label %exit
44 br i1 undef, label %outer.header, label %exit
49 %exit.phi = phi i32 [ %inc, %inner.latch ], [ undef, %outer.latch ]