[PATCH] Plug optimization hole in constant folder

Richard Guenther richard.guenther@gmail.com
Mon Sep 17 20:25:00 GMT 2007


On 9/17/07, Andrew Pinski <pinskia@gmail.com> wrote:
> On 9/17/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> > It looks straight-forward, but I fear of potential impact on compile-time.
> > Can you at least restrict the transformation to indices of INTEGER_CST
> > kind?  Can you check if it is possible to use binary search on the
> > array constructor (I seem to remember we keep the elements sorted)?
>
> I don't think we will see that many ARRAY_REF of CONSTRUCTORs so the
> compile time issue should be mute.  Though I am worried about
> ADDR_EXPR < ARRAY_REF<CONSTRUCTOR, 0 > > being folded into
> ADDR_EXPR<DECL> where DECL is the CONSTRUCTOR's value for index 0.

We should have the same issue for structs, but yes - ADDR_EXPR is special
and I think we pay special attention to not blindly fold ADDR_EXPRs
argument.  Note that we have the long-time PR12245, so large initializers
happen.  Even a single linear walk through the CONSTRUCTOR is bad
(though the same issue exists for large sturctures).  Of course fixing this
representation issue is independent of this patch.  Just we can avoid
walking all of the array elements if the index asked for is not a constant.

Richard.



More information about the Gcc-patches mailing list