1 ; RUN: opt < %s -passes=indvars -S | FileCheck %s
2 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 declare void @use(i64 %x)
15 ; CHECK: %[[INDVAR:.*]] = phi i64
16 ; CHECK: %[[TRUNC:.*]] = trunc nuw nsw i64 %[[INDVAR]] to i32
18 %i = phi i32 [ 0, %L1_header ], [ %i_next, %L2_latch ]
19 %i_prom = sext i32 %i to i64
20 call void @use(i64 %i_prom)
24 br i1 undef, label %L3_latch, label %L2_exiting_1
27 br i1 undef, label %L3_header, label %L2_exiting_2
30 br i1 undef, label %L2_latch, label %L1_latch
33 br i1 undef, label %L2_latch, label %L1_latch
36 %i_next = add nsw i32 %i, 1
41 ; CHECK: %i_lcssa = phi i32 [ %[[TRUNC]], %L2_exiting_1 ], [ %[[TRUNC]], %L2_exiting_2 ]
43 %i_lcssa = phi i32 [ %i, %L2_exiting_1 ], [ %i, %L2_exiting_2 ]
44 br i1 undef, label %exit, label %L1_header