> -----Original Message----- > From: Richard Guenther [mailto:richard.guent...@gmail.com] > Sent: 03 August 2010 17:22 > To: Bingfeng Mei > Cc: Alexander Monakov; gcc@gcc.gnu.org > Subject: Re: Restrict qualifier still not working? > > On Tue, Aug 3, 2010 at 6:11 PM, Bingfeng Mei <b...@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)))) > Thanks, this patch works with trunk x86.
> 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). Is this gigantic patch you referring to? 2010-07-01 Richard Guenther <rguent...@suse.de> PR middle-end/42834 PR middle-end/44468 * doc/gimple.texi (is_gimple_mem_ref_addr): Document. * doc/generic.texi (References to storage): Document MEM_REF. * tree-pretty-print.c (dump_generic_node): Handle MEM_REF. (print_call_name): Likewise. * tree.c (recompute_tree_invariant_for_addr_expr): Handle MEM_REF. (build_simple_mem_ref_loc): New function. (mem_ref_offset): Likewise. * tree.h (build_simple_mem_ref_loc): Declare. (build_simple_mem_ref): Define. (mem_ref_offset): Declare. * fold-const.c: Include tree-flow.h. (operand_equal_p): Handle MEM_REF. (build_fold_addr_expr_with_type_loc): Likewise. (fold_comparison): Likewise. (fold_unary_loc): Fold VIEW_CONVERT_EXPR <T1, MEM_REF <T2, ...>> to MEM_REF <T1, ...>. (fold_binary_loc): Fold MEM[&MEM[p, CST1], CST2] to MEM[p, CST1 + CST2], fold MEM[&a.b, CST2] to MEM[&a, offsetof (a, b) + CST2]. * tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Handle MEM_REF. (ptr_deref_may_alias_ref_p_1): Likewise. (ao_ref_base_alias_set): Properly differentiate base object for offset and TBAA. (ao_ref_init_from_ptr_and_size): Use MEM_REF. (indirect_ref_may_alias_decl_p): Handle MEM_REFs properly. (indirect_refs_may_alias_p): Likewise. (refs_may_alias_p_1): Likewise. Remove pointer SSA name def chasing code. (ref_maybe_used_by_call_p_1): Handle MEM_REF. (call_may_clobber_ref_p_1): Likewise. * dwarf2out.c (loc_list_from_tree): Handle MEM_REF. > > Thanks, > Richard.