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