1 ; RUN: opt < %s -loop-unroll -unroll-runtime -unroll-count=2 -verify-scev-maps -S | FileCheck %s
3 ; Check SCEV expansion uses existing value when unrolling an inner loop with runtime trip count in a loop nest.
9 define void @foo(i32 %xfL, i32 %scaleL) local_unnamed_addr {
13 for.body: ; preds = %for.body5, %for.body, %entry
14 %xfL.addr.033 = phi i32 [ %xfL, %entry ], [ %add, %for.body5 ]
15 %add = add nsw i32 %xfL.addr.033, %scaleL
16 %shr = ashr i32 %add, 16
17 %cmp.i = icmp slt i32 0, %shr
18 %.sroa.speculated = select i1 %cmp.i, i32 0, i32 %shr
19 %cmp425 = icmp slt i32 0, %.sroa.speculated
20 br i1 %cmp425, label %for.body5.preheader, label %for.end
22 for.body5.preheader: ; preds = %for.body
23 %tmp0 = sext i32 %.sroa.speculated to i64
26 for.body5: ; preds = %for.body5, %for.body5.preheader
27 %indvars.iv = phi i64 [ 0, %for.body5.preheader ], [ %indvars.iv.next, %for.body5 ]
28 %indvars.iv.next = add nsw i64 %indvars.iv, 1
29 %cmp4 = icmp slt i64 %indvars.iv.next, %tmp0
30 br i1 %cmp4, label %for.body5, label %for.body