[Patch] Silent gcc 4.2.0 loop optimization bug with -O2

Ed Schouten ed at fxq.nl
Wed Jul 4 12:12:11 UTC 2007


Hello,

This morning I received the following message from GCC's Bugzilla:

----- Forwarded message from rguenth at gcc dot gnu dot org <gcc-bugzilla at gcc.gnu.org> -----
> Date: 4 Jul 2007 10:16:52 -0000
> From: rguenth at gcc dot gnu dot org <gcc-bugzilla at gcc.gnu.org>
> To: ed at fxq.nl
> Reply-To: gcc-bugzilla at gcc.gnu.org
> Subject: [Bug tree-optimization/32500] [4.2 Regression] Loop optimization
> 	limits range to size of array used inside loop
> 
> [snip]
> 
> scev_probably_wraps_p() returns false for the above chrec because for
> the loop in question estimated_nb_iterations is 4(!) which is derived
> from infer_loop_bounds_from_undefined.  On the trunk this is fixed
> by rewriting number of iterations analysis.  On the 4.2 branch we
> can fix this conservatively by
> 
> Index: tree-ssa-loop-niter.c
> ===================================================================
> --- tree-ssa-loop-niter.c       (revision 126260)
> +++ tree-ssa-loop-niter.c       (working copy)
> @@ -1747,6 +1747,12 @@ infer_loop_bounds_from_undefined (struct
>      {
>        bb = bbs[i];
> 
> +      /* If BB is not executed in each iteration of the loop, we cannot
> +        use the operations in it to infer reliable upper bound on the
> +        # of iterations of the loop.  */
> +      if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
> +       continue;
> +
>        for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
>          {
>           tree stmt = bsi_stmt (bsi);
> 
> I'm going to test this.
> 
----- End forwarded message -----

I just tested the patch on my desktop and it seems to work. The test
code now compiles like it should. Hopefully it will be part of 4.2.1.

Yours,
-- 
 Ed Schouten <ed at fxq.nl>
 WWW: http://g-rave.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070704/067bc151/attachment.pgp


More information about the freebsd-current mailing list