On Tue, Aug 3, 2010 at 6:38 PM, Bingfeng Mei <b...@broadcom.com> wrote:
>
>
>> -----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?

No, more like

2010-07-23  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/45037
        * tree-ssa-loop-ivopts.c (copy_ref_info): Handle NULL base.

2010-07-05  Richard Guenther  <rguent...@suse.de>

        * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Copy alias info.

2010-07-05  Richard Guenther  <rguent...@suse.de>

        * tree.c (reference_alias_ptr_type): New function.
        * tree.h (reference_alias_ptr_type): Declare.
        * tree-ssa-loop-ivopts.c (copy_ref_info): Restructure to
        allow non-TARGET_MEM_REF new refs.
        (rewrite_use_address): Pass old alias pointer type to create_mem_ref.
        * tree-ssa-address.c (create_mem_ref_raw): Get alias pointer type.
        Build a MEM_REF instead of a TARGET_MEM_REF if possible.
        (create_mem_ref): Get alias pointer type.  Adjust calls to
        create_mem_ref_raw.
        (maybe_fold_tmr): Likewise.
        * tree-flow.h (create_mem_ref): Adjust prototype.

2010-07-04  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/44479
        * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Avoid
        extra SSA name copy statements which preserves points-to
        information.
        * tree-vect-data-refs.c (vect_create_addr_base_for_vector_ref):
        Copy points-to information for all pointers.  Properly handle
        MEM_REFs.
        (vect_create_data_ref_ptr): Likewise.  Avoid extra SSA name
        copy statements.
        * Makefile.in (tree-ssa-loop-ivopts.o): Add tree-ssa-propagate.h
        dependency.

2010-07-02  Richard Guenther  <rguent...@suse.de>

        * tree-ssa-structalias.c (pt_solution_set_var): New function.
        * tree-ssa-alias.h (pt_solution_set_var): Declare.
        * tree-ssa-loop-ivopts.c (copy_ref_info): Also copy or create
        points-to information.

well - all the pieces that apply.  The above went in after the
gigantic patch you refered to which makes most pieces need
adjustments for the branch.

RIchard.


> 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.
>
>
>

Reply via email to