<div dir="ltr"><a href="https://llvm.org/bugs/show_bug.cgi?id=25378">https://llvm.org/bugs/show_bug.cgi?id=25378</a><br><div><br></div><div>Thanks!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 12:26 PM, Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+ Christian<br>
<span class=""><br>
On Mon, Nov 02, 2015 at 12:14:46PM -0500, Justin Holewinski via llvm-dev wrote:<br>
> Hi,<br>
><br>
> I've been investigating the StructurizeCFG pass, and it looks like it has<br>
> trouble handling CFG edges that break out of a loop and go directly to the<br>
> function exit. Am I running up against a bug in the structurizer, or a<br>
> general limitation of the algorithm used? As an aside, is there any<br>
> documentation for the algorithm used? Is it based on a published paper?<br>
><br>
<br>
</span>I'm not aware of any limitations, so this is a bug. Can you file one at<br>
<a href="http://llvm.org/bugs" rel="noreferrer" target="_blank">llvm.org/bugs</a>.<br>
<br>
-Tom<br>
<div><div class="h5"><br>
><br>
> The input IR I have is the following:<br>
><br>
> define <4 x float> @structurizer_test(<4 x float> %inp.coerce) {<br>
> %1 = extractelement <4 x float> %inp.coerce, i32 0<br>
> %2 = fcmp ogt float %1, 0.000000e+00<br>
> br i1 %2, label %.lr.ph.i, label %._crit_edge.i<br>
><br>
> .lr.ph.i: ; preds = %7, %0<br>
> %i.03.i = phi float [ %8, %7 ], [ 0.000000e+00, %0 ]<br>
> %ret.02.i = phi <4 x float> [ %5, %7 ], [ <float 1.000000e+00, float<br>
> 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %0 ]<br>
> %3 = extractelement <4 x float> %ret.02.i, i32 0<br>
> %4 = fadd fast float %3, 0xBFB99999A0000000<br>
> %5 = insertelement <4 x float> %ret.02.i, float %4, i32 0<br>
> %6 = fcmp olt float %4, 5.000000e-01<br>
> br i1 %6, label %_Z9get_colorDv2_f.exit, label %7<br>
><br>
> ; <label>:7 ; preds = %.lr.ph.i<br>
> %8 = fadd fast float %i.03.i, 1.000000e+01<br>
> %9 = fcmp olt float %8, %1<br>
> br i1 %9, label %.lr.ph.i, label %._crit_edge.i<br>
><br>
> ._crit_edge.i: ; preds = %7, %0<br>
> %ret.0.lcssa.i = phi <4 x float> [ <float 1.000000e+00, float<br>
> 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %0 ], [ %5, %7 ]<br>
> %10 = insertelement <4 x float> %ret.0.lcssa.i, float 0.000000e+00, i32 2<br>
> br label %_Z9get_colorDv2_f.exit<br>
><br>
> _Z9get_colorDv2_f.exit: ; preds = %._crit_edge.i,<br>
> %.lr.ph.i<br>
> %.0.i = phi <4 x float> [ %10, %._crit_edge.i ], [ %5, %.lr.ph.i ]<br>
> ret <4 x float> %.0.i<br>
> }<br>
><br>
> After structurization, I have a module that has what looks like a<br>
> reasonable CFG, but bad branch conditions and PHIs:<br>
><br>
> define <4 x float> @structurizer_test(<4 x float> %inp.coerce) {<br>
> %1 = extractelement <4 x float> %inp.coerce, i32 0<br>
> %2 = fcmp ogt float %1, 0.000000e+00<br>
> %3 = xor i1 %2, true<br>
> br label %Flow<br>
><br>
> Flow: ; preds = %Flow1, %0<br>
> %4 = phi <4 x float> [ %14, %Flow1 ], [ <float 1.000000e+00, float<br>
> 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %0 ]<br>
> %5 = phi <4 x float> [ %16, %Flow1 ], [ <float 1.000000e+00, float<br>
> 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %0 ]<br>
> %6 = phi float [ %17, %Flow1 ], [ 0.000000e+00, %0 ]<br>
> %7 = phi i1 [ %18, %Flow1 ], [ %3, %0 ]<br>
> %8 = phi i1 [ false, %Flow1 ], [ %2, %0 ]<br>
> br i1 %8, label %.lr.ph.i, label %Flow1<br>
><br>
> .lr.ph.i: ; preds = %Flow<br>
> %i.03.i = phi float [ %6, %Flow ]<br>
> %ret.02.i = phi <4 x float> [ %5, %Flow ]<br>
> %9 = extractelement <4 x float> %ret.02.i, i32 0<br>
> %10 = fadd fast float %9, 0xBFB99999A0000000<br>
> %11 = insertelement <4 x float> %ret.02.i, float %10, i32 0<br>
> %12 = fcmp olt float %10, 5.000000e-01<br>
> %13 = xor i1 %12, true<br>
> br i1 %13, label %19, label %Flow2<br>
><br>
> Flow1: ; preds = %Flow2, %Flow<br>
> %14 = phi <4 x float> [ %23, %Flow2 ], [ %4, %Flow ]<br>
</div></div>> %15 = phi <4 x float> [ %11, %Flow2 ], [ *undef*, %Flow ]<br>
<span class="">> %16 = phi <4 x float> [ %24, %Flow2 ], [ %5, %Flow ]<br>
> %17 = phi float [ %25, %Flow2 ], [ %6, %Flow ]<br>
> %18 = phi i1 [ %26, %Flow2 ], [ %7, %Flow ]<br>
</span>> br i1 *true*, label %Flow3, label %Flow<br>
<span class="">><br>
> ; <label>:19 ; preds = %.lr.ph.i<br>
> %20 = fadd fast float %i.03.i, 1.000000e+01<br>
> %21 = fcmp olt float %20, %1<br>
> %22 = xor i1 %21, true<br>
> br label %Flow2<br>
><br>
> Flow2: ; preds = %19, %.lr.ph.i<br>
> %23 = phi <4 x float> [ %11, %19 ], [ %4, %.lr.ph.i ]<br>
</span>> %24 = phi <4 x float> [ %11, %19 ], [ *undef*, %.lr.ph.i ]<br>
<span class="">> %25 = phi float [ %20, %19 ], [ undef, %.lr.ph.i ]<br>
> %26 = phi i1 [ %22, %19 ], [ %7, %.lr.ph.i ]<br>
> br label %Flow1<br>
><br>
> Flow3: ; preds = %Flow1<br>
> br i1 %18, label %._crit_edge.i, label %_Z9get_colorDv2_f.exit<br>
><br>
> ._crit_edge.i: ; preds = %Flow3<br>
> %ret.0.lcssa.i = phi <4 x float> [ %14, %Flow3 ]<br>
> %27 = insertelement <4 x float> %ret.0.lcssa.i, float 0.000000e+00, i32 2<br>
> br label %_Z9get_colorDv2_f.exit<br>
><br>
> _Z9get_colorDv2_f.exit: ; preds = %._crit_edge.i,<br>
> %Flow3<br>
> %.0.i = phi <4 x float> [ %15, %Flow3 ], [ %27, %._crit_edge.i ]<br>
> ret <4 x float> %.0.i<br>
> }<br>
><br>
> Note the undef values in some of the PHIs and 'i1 true' for the loop branch<br>
> condition.<br>
><br>
><br>
><br>
> --<br>
><br>
> Thanks,<br>
><br>
> Justin Holewinski<br>
<br>
<br>
</span>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br><div>Thanks,</div><div><br></div><div>Justin Holewinski</div></div>
</div>