[patch] Fix minor SLSR pessimization
Bill Schmidt
wschmidt@linux.ibm.com
Fri Aug 2 14:50:00 GMT 2019
On 8/2/19 8:15 AM, Eric Botcazou wrote:
> Hi,
>
> an user reported that, for pairs of consecutive memory accesses, the SLSR pass
> can slightly pessimize the generated code at -O2 on the x86 architecture:
>
> struct x
> {
> int a[16];
> int b[16];
> };
>
> void
> set (struct x *p, unsigned int n, int i)
> {
> p->a[n] = i;
> p->b[n] = i;
> }
>
> is compiled with SLSR enabled into:
>
> leaq (%rdi,%rsi,4), %rax
> movl %edx, (%rax)
> movl %edx, 64(%rax)
>
> which is slightly worse than the expected:
>
> movl %edx, (%rdi,%rsi,4)
> movl %edx, 64(%rdi,%rsi,4)
>
> The attached patch is a tentative fix which doesn't seem to break anything.
>
> Tested on x86_64-suse-linux, OK for the mainline?
OK. Thanks for the patch!
Bill
>
>
> 2019-08-02 Eric Botcazou <ebotcazou@adacore.com>
>
> * gimple-ssa-strength-reduction.c (valid_mem_ref_cand_p): New function.
> (replace_ref): Do not replace a chain of only two candidates which are
> valid memory references.
>
>
> 2019-08-02 Eric Botcazou <ebotcazou@adacore.com>
>
> * gcc.dg/tree-ssa/slsr-42.c: New test.
>
More information about the Gcc-patches
mailing list