------- Comment #2 from bonzini at gnu dot org  2006-09-07 08:11 -------
It's not really CSE's fault, though I agree that doing addressing mode
selection there is wrong.  fwprop does not fix the bug for example, though
teaching it about this case could be easier than teaching CSE.

Unlike CSE, fwprop fixes this case:

char a[10], b[10];

int f1(log i)
{
        return a[i+1] + b[i+1];
}

which generates

        incq    %rdi
        movsbl  a(%rdi),%eax
        movsbl  b(%rdi),%edx
        addl    %edx, %eax

with current GCC.  So one way to fix this bug (assuming fwprop is merged in
4.3) is to teach something (expand?) that


(set (reg:DI 58 [ D.1872 ])
        (sign_extend:DI (reg:SI 60 [ D.1872 ])))

(parallel [
            (set (reg:DI 62 [ D.1872 ])
                (plus:DI (reg/v:DI 58 [ i ])
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ])

at least when we can disregard overflow, might be better than

(parallel [
            (set (reg:SI 58 [ D.1872 ])
                (plus:SI (reg/v:SI 60 [ i ])
                    (const_int 1 [0x1])))
            (clobber (reg:CC 17 flags))
        ])

(set (reg:DI 62 [ D.1872 ])
        (sign_extend:DI (reg:SI 58 [ D.1872 ])))


-- 

bonzini at gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bonzini at gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28940

Reply via email to