xref: /aosp_15_r20/external/llvm/test/Transforms/IndVarSimplify/pr25578.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -indvars -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @foo
5*9880d681SAndroid Build Coastguard Workerdefine void @foo() {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker  br label %L1_header
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard WorkerL1_header:
10*9880d681SAndroid Build Coastguard Worker  br label %L2_header
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; CHECK: L2_header:
13*9880d681SAndroid Build Coastguard Worker; CHECK: %[[INDVAR:.*]] = phi i64
14*9880d681SAndroid Build Coastguard Worker; CHECK: %[[TRUNC:.*]] = trunc i64 %[[INDVAR]] to i32
15*9880d681SAndroid Build Coastguard WorkerL2_header:
16*9880d681SAndroid Build Coastguard Worker  %i = phi i32 [ 0, %L1_header ], [ %i_next, %L2_latch ]
17*9880d681SAndroid Build Coastguard Worker  %i_prom = sext i32 %i to i64
18*9880d681SAndroid Build Coastguard Worker  br label %L3_header
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard WorkerL3_header:
21*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %L3_latch, label %L2_exiting_1
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard WorkerL3_latch:
24*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %L3_header, label %L2_exiting_2
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard WorkerL2_exiting_1:
27*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %L2_latch, label %L1_latch
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard WorkerL2_exiting_2:
30*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %L2_latch, label %L1_latch
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard WorkerL2_latch:
33*9880d681SAndroid Build Coastguard Worker  %i_next = add nsw i32 %i, 1
34*9880d681SAndroid Build Coastguard Worker  br label %L2_header
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard WorkerL1_latch:
37*9880d681SAndroid Build Coastguard Worker; CHECK: L1_latch:
38*9880d681SAndroid Build Coastguard Worker; CHECK: %i_lcssa = phi i32 [ %[[TRUNC]], %L2_exiting_1 ], [ %[[TRUNC]], %L2_exiting_2 ]
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker  %i_lcssa = phi i32 [ %i, %L2_exiting_1 ], [ %i, %L2_exiting_2 ]
41*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %exit, label %L1_header
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerexit:
44*9880d681SAndroid Build Coastguard Worker  ret void
45*9880d681SAndroid Build Coastguard Worker}
46