https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491

--- Comment #12 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 12 Jun 2019, wschmidt at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491
> 
> Bill Schmidt <wschmidt at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Target|arm-none-eabi               |arm-none-eabi, powerpc*-*-*
>                  CC|                            |wschmidt at gcc dot gnu.org
> 
> --- Comment #10 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
> This remains a problem and was rediscovered recently here with GCC 10. 
> However, it seems worse than before in that conditions "c" and "d" of the
> original bug report are no longer necessary to get the unnecessary temporary.
> 
> /* test case */
> struct foo {
>         int bar;
>         int baz;
> };
> 
> register struct foo *local asm("r13");
> 
> void fn(void)
> {
>         if (local->bar)
>                 local->bar = 0;
>         local->baz--;
> }
> /* end test case */
> 
> Compile with -O2.  As in the other case, the copy-to-temporary is introduced 
> at
> gimplification and remains in place at expand time.
> 
> wschmidt@marlin:~/src$ cat nick2.c.005t.gimple
> fn ()
> {
>   local.0_1 = local;

There's a conflict of interest here.  We do not consider hard-registers
as GIMPLE registers and thus do not rewrite them into SSA.  This in
turn requires "loads" from them to make the indirection valid GIMPLE.

If we'd rewrite the hard registers into SSA it's much harder to avoid
messing with them (we might get away with setting 
SSA_NAME_OCCURS_IN_ABNORMAL_PHI on them, who knows).

Note that we happily create overlapping life-ranges of the loaded
hardreg SSA names thus propagating those out isn't the solution
either.  I guess one idea would be to make out-of-SSA rewrite
the hardregs into SSA and then prioritize SSA coalescing to
coalesce the now SSA copies with higher priority as others.
The easiest way to trick the SSA rewriter to allow rewriting
hardregs would be to extend DECL_IS_GIMPLE_REG_P to apply
to hardregs.

No time to do all this but the out-of-SSA coalescing strategy
looks easiest.

Reply via email to