[PATCH] fwprop: Prevent infinite looping (PR79405)
Jeff Law
law@redhat.com
Fri Mar 31 23:28:00 GMT 2017
On 03/23/2017 08:58 AM, Segher Boessenkool wrote:
> The algorithm fwprop uses never reconsiders a possible propagation,
> although it could succeed if the def (in the def-use to propagate)
> has changed. This causes fwprop to do infinite propagations, like
> in the scenario in the PR, where we end up with effectively
> B = A
> A = B
> D = A
> where only propagations into the last statement are still tried, and
> that loops (it becomes D = B, then back to D = A, etc.)
>
> Fixing this properly isn't easy; this patch instead limits the number
> of propagations performed to the number of uses we originally had,
> which is the maximum number of propagations that can be done if there
> are no such infinite loops.
>
> Bootstrapped and regression checked on powerpc64-linux {-m64,-m32};
> is this okay for trunk?
>
>
> Segher
>
>
> 2017-03-23 Segher Boessenkool <segher@kernel.crashing.org>
>
> PR rtl-optimization/79405
> * fwprop.c (propagations_left): New variable.
> (forward_propagate_into): Decrement it.
> (fwprop_init): Initialize it.
> (fw_prop): If the variable has reached zero, stop propagating.
> (fwprop_addr): Ditto.
>
> gcc/testsuite/
> PR rtl-optimization/79405
> gcc.dg/pr79405.c: New testcase.
I installed this as a stopgap for gcc-7. The bug is still open
targetting gcc-8 to force us to come back and look at Richi's suggestion.
jeff
More information about the Gcc-patches
mailing list