This is the mail archive of the gcc@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: Restrict qualifier still not working?


On Tue, Aug 3, 2010 at 6:11 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> Richard,
> I applied the patch. The simple example in my previous mail is
> compiled as expected. However, for a bit more complex example,
> restrict qualifier still doesn't work as expected. This happens
> even on trunk compiler so it is not due to some missing patches on 4.5.
>
> void foo (int * restrict a, int * restrict b, int * restrict c)
> {
> ? int i;
> ? for(i = 0; i < 100; i+=4)
> ? ? {
> ? ? ? a[i] = b[i] * c[i];
> ? ? ? a[i+1] = b[i+1] * c[i+1];
> ? ? ? a[i+2] = b[i+2] * c[i+2];
> ? ? ? a[i+3] = b[i+3] * c[i+3];
> ? ? }
> }
>
> ~/work/install-x86/bin/gcc tst3.c -O2 -S -std=c99 -da -fschedule-insns -frename-register
>
> .L2:
> ? ? ? ?movl ? ?(%rdx,%rax), %r10d
> ? ? ? ?imull ? (%rsi,%rax), %r10d
> ? ? ? ?movl ? ?%r10d, (%rdi,%rax)
> ? ? ? ?movl ? ?4(%rdx,%rax), %r9d
> ? ? ? ?imull ? 4(%rsi,%rax), %r9d
> ? ? ? ?movl ? ?%r9d, 4(%rdi,%rax)
> ? ? ? ?movl ? ?8(%rdx,%rax), %r8d
> ? ? ? ?imull ? 8(%rsi,%rax), %r8d
> ? ? ? ?movl ? ?%r8d, 8(%rdi,%rax)
> ? ? ? ?movl ? ?12(%rdx,%rax), %ecx
> ? ? ? ?imull ? 12(%rsi,%rax), %ecx
> ? ? ? ?movl ? ?%ecx, 12(%rdi,%rax)
> ? ? ? ?addq ? ?$16, %rax
> ? ? ? ?cmpq ? ?$400, %rax
> ? ? ? ?jne ? ? .L2
> ? ? ? ?rep
>
> This used to compile efficiently on our 4.4 port. Any comments?

It's due to TMR_ORIGINAL being used for MEM_EXPRs during
expansion (and TMRs not being handled by the alias oracles
well).  I can look at this if you file a bugreport, so I remember.

A patch as simple as

Index: expr.c
===================================================================
--- expr.c      (revision 162841)
+++ expr.c      (working copy)
@@ -8665,7 +8665,7 @@ expand_expr_real_1 (tree exp, rtx target
        set_mem_addr_space (temp, as);
        base = get_base_address (TMR_ORIGINAL (exp));
        if (base
-           && INDIRECT_REF_P (base)
+           && (INDIRECT_REF_P (base) || TREE_CODE (base) == MEM_REF)
            && TMR_BASE (exp)
            && TREE_CODE (TMR_BASE (exp)) == SSA_NAME
            && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (exp))))

might help.  On the 4.5 branch you need to backport the various
changes to retain points-to info during IVOPTs (or use -fno-tree-ivopts).

Thanks,
Richard.


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