This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix ICE during RTL expansion at -O1


On Thu, Mar 21, 2013 at 5:24 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this fixes an ICE on the mainline at -O1:
>
> eric@polaris:~/gnat/bugs/M129-026> ~/install/gcc/bin/gcc -S p.adb -O
> +===========================GNAT BUG DETECTED==============================+
> | 4.9.0 20130320 (experimental) [trunk revision 196816] (x86_64-suse-linux)
> GCC error:|
> | in expand_assignment, at expr.c:4761                                     |
> | Error detected around p.ads:11:9
>
>   MEM[(struct p__rec &)&ret].d = 0;
>   MEM[(struct p__rec &)&ret].b1 = 0;
>   _26 = MEM[(struct p__rec &)&ret].d;
>   p0.8_27 = (integer) _26;
>   _28 = (sizetype) p0.8_27;
>   _29 = _28 * 8;
>   _30 = _29 + _29;
>   _31 = _30 + 8;
>   _32 = _31 /[ex] 8;
>   MEM[(struct p__rec &)&ret].b2{off: _32 * 8} = 1;
>
> The ICE occurs because ret is put into a register instead of memory (it has
> an integral mode) and you cannot have a variable offset within an object in
> a register.
>
> But, if you look at the above GIMPLE from .optimized, you'll see that the
> offset is actually fixed and that the GIMPLE optimizers weren't powerful
> enough to see it.  Ironically enough, the RTL optimizers would have been!
>
> So the attached patch adds a clone of nonoverlapping_component_refs_p from
> alias.c to tree-ssa-alias.c to disambiguate the memory accesses.  It also
> contains a small tweak to both functions to cater to a LTO-specific quirk.
>
> With it, a bunch of testcases of the vectorization testsuite are optimized
> so the patch also contains counter-measures for them.
>
> Tested on x86_64-suse-linux, OK for the mainline?

This is a quadratic algorithm and as such not ok.  We already have
aliasing_component_refs_p in tree-ssa-alias.c which is supposed to be
the non-quadratic replacement.  It's not used via decl_refs_may_alias_p,
so that may be the thing to fix.

nonoverlapping_component_refs_of_decl_p on RTL should go - in fact
we do call the tree oracle from all its callers so we only ever do redundant
work (after your proposed patch even more so).

(I recently tried to cache the ao_ref in mem-attrs but failed because of
weird gengtype issues ... we could avoid the repeated get_ref_base_and_extent
calls done via ao_ref_from_mem that way).

Richard.

>
> 2013-03-21  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * alias.c (nonoverlapping_component_refs_p): Protect again LTO quirk.
>         * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): New.
>         (decl_refs_may_alias_p): Add REF1 and REF2 parameters.
>         Use it to disambiguate component references.
>         (refs_may_alias_p_1): Adjust call to decl_refs_may_alias_p.
>
>
> 2013-03-21  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gnat.dg/discr41.ad[sb]: New test.
>         * gcc.dg/vect/slp-24-big-array.c: Beef up anti-vectorization trick.
>         * gcc.dg/vect/slp-24.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-mult.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u16-i2.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u16-i4.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u16-mult.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u8-i2-gap.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u8-i8-gap2-big-array.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u8-i8-gap2.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u8-i8-gap7-big-array.c: Likewise.
>         * gcc.dg/vect/vect-strided-a-u8-i8-gap7.c: Likewise.
>         * gcc.dg/vect/vect-strided-mult-char-ls.c: Likewise.
>         * gcc.dg/vect/vect-strided-mult.c: Likewise.
>         * gcc.dg/vect/vect-strided-same-dr.c: Likewise.
>         * gcc.dg/vect/vect-strided-u16-i2.c: Likewise.
>         * gcc.dg/vect/vect-strided-u16-i4.c: Likewise.
>         * gcc.dg/vect/vect-strided-u32-i4.c: Likewise.
>         * gcc.dg/vect/vect-strided-u32-i8.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i2-gap.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i2.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap2-big-array.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap2.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap4-big-array.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap4-unknown.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap4.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap7-big-array.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8-gap7.c: Likewise.
>         * gcc.dg/vect/vect-strided-u8-i8.c: Likewise.
>
>
> --
> Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]