2015-12-16 10:08 GMT+03:00 Senthil Kumar Selvaraj
<senthil_kumar.selva...@atmel.com>:
> Hi,
>
>   When analyzing code size regressions for AVR for top-of-trunk, I
>   found a few cases where aggresive inlining (by the middle-end)
>   of functions containing calls to memcpy was bloating up the code.
>
>   Turns out that the AVR backend has MOVE_MAX set to 4 (unchanged from the
>   original commit), when it really should be 1, as the AVRs can only
>   move a single byte between reg and memory in a single instruction.
>   Setting it to 4 causes the middle end to underestimate the
>   cost of memcopys with a compile time constant length parameter, as it
>   thinks a 4 byte copy's cost is only a single instruction.
>
>   Just setting MOVE_MAX to 1 makes the middle end too conservative
>   though, and causes a bunch of regression tests to fail, as lots of
>   optimizations fail to pass the code size increase threshold check,
>         even when not optimizing for size.
>
>   Instead, the below patch sets MOVE_MAX_PIECES to 2, and implements a
>   target hook that tells the middle-end to use load/store insns for
>   memory moves upto two bytes. Also, the patch sets MOVE_RATIO to 3 when
>   optimizing for speed, so that moves upto 4 bytes will occur through
>   load/store sequences, like it does now.
>
>   With this, only a couple of regression tests fail. uninit-19.c fails
>   because it thinks only non-pic code won't inline a function, but the
>   cost computation prevents inlining for AVRs. The test passes if
>   the optimization level is increased to -O3.
>
>         strlenopt-8.c has an XPASS and a FAIL because a previous pass issued
>         a builtin_memcpy instead of a MEM assignment. Execution still passes.
>
>   I'll continue running more tests to see if there are other performance
>   related consequences.
>
>   Is this ok? If ok, could someone commit please? I don't have commit
>   access.
>
> Regards
> Senthil
>
> gcc/ChangeLog
>
> 2015-12-16  Senthil Kumar Selvaraj  <senthil_kumar.selva...@atmel.com>
>
>         * config/avr/avr.h (MOVE_MAX): Set value to 1.
>         (MOVE_MAX_PIECES): Define.
>         (MOVE_RATIO): Define.
>         * config/avr/avr.c (TARGET_USE_BY_PIECES_INFRASTRUCTURE_P):
>         Provide target hook.
>         (avr_use_by_pieces_infrastructure_p): New function.

Committed.

Denis.

Reply via email to