Hi,
I ran a small test to see how the trunk/4.5 works 
with the rewritten restrict qualified pointer code. But it doesn't
seem to work on both x86-64 and our port. 

tst.c:
void foo (int * restrict a, int * restrict b,
          int * restrict c, int * restrict d)
{
  *c = *a + 1;
  *d = *b + 1;
}

tst.c.141r.expand (4.5.0)
;; *c_4(D) = D.2576_3;

(insn 9 8 10 tst2.c:4 (set (reg:SI 67)
        (mem:SI (reg/v/f:DI 62 [ a ]) [2 S4 A32])) -1 (nil))

(insn 10 9 11 tst2.c:4 (parallel [
            (set (reg:SI 66)
                (plus:SI (reg:SI 67)
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil))

(insn 11 10 0 tst2.c:4 (set (mem:SI (reg/v/f:DI 64 [ c ]) [2 S4 A32])
        (reg:SI 66)) -1 (expr_list:REG_EQUAL (plus:SI (mem:SI (reg/v/f:DI 62 [ 
a ]) [2 S4 A32])
            (const_int 1 [0x1]))
        (nil)))

;; *d_8(D) = D.2578_7;

(insn 12 11 13 tst2.c:5 (set (reg:SI 69)
        (mem:SI (reg/v/f:DI 63 [ b ]) [2 S4 A32])) -1 (nil))

(insn 13 12 14 tst2.c:5 (parallel [
            (set (reg:SI 68)
                (plus:SI (reg:SI 69)
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ]) -1 (nil))

(insn 14 13 0 tst2.c:5 (set (mem:SI (reg/v/f:DI 65 [ d ]) [2 S4 A32])
        (reg:SI 68)) -1 (expr_list:REG_EQUAL (plus:SI (mem:SI (reg/v/f:DI 63 [ 
b ]) [2 S4 A32])
            (const_int 1 [0x1]))
        (nil)))

All the memory expression in the RTL have alias set of 2, which
isn't right IMO. 

With trunk GCC, memory attribute is represented as:
[2 *a_1(D)+0 S4 A32]. Will the extra *a_1(D)+0 differentiate
alias sets even the number are the same for all MEM expression?

foo:
.LFB0:
        .cfi_startproc
        movl    (%rdi), %eax
        addl    $1, %eax
        movl    %eax, (%rdx)
        movl    (%rsi), %eax
        addl    $1, %eax
        movl    %eax, (%rcx)
        ret

In the finally generated code, the second load should have
been moved before the first store if restrict qualifiers
are handled correctly. 

Am I missing something here? Thanks. 

Cheers,
Bingfeng

Reply via email to