Thanks to Tom <[EMAIL PROTECTED]>.

Program:
    void * memset (void *buf, int val, unsigned int n);
    void foo (void)
    {
        memset ((char *)0x4000, 0, 0x4000);
    }
is compiled into wrong code, where pointer and counter use 1 register pair:
        ldi r30,lo8(16384)
        ldi r31,hi8(16384)
        st Z+,__zero_reg__
        sbiw r30,1
        brne .-6
Compiler: 4.1.1
Options: -W -Wall -Os -S

I have try a set of versions:
        avr-gcc 3.3.5  - OK, loop counter is separate register pair
        avr-gcc 3.4.4, 4.0.2, 4.1.1  - wrong code.

Possible, the reason is in absence of '&' in clobber statement 'avr.md':
   ...
   (use (match_operand:HI 1 "register_operand" "!w,d"))
   (use (match_operand:HI 2 "const_int_operand" "n,n"))
   (clobber (match_scratch:HI 3 "=0,0"))
   (clobber (match_scratch:HI 4 "=1,1"))]
   ...


-- 
           Summary: avr-gcc: builtin memset(): wrong code
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dmixm at marine dot febras dot ru


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

Reply via email to