This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/45813] New: alias analysis problem ?


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

           Summary: alias analysis problem ?
           Product: gcc
           Version: 4.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: darrenrjenkins@gmail.com


I think I am having some wrong code generated due to a compiler bug.
I am compiling for ARM/Thumb.

USB_INT16U  ReadLE16U ( volatile USB_INT08U  *pmem )
{
    USB_INT16U  val;
    USB_INT08U *bytes = (USB_INT08U *)&val;

    bytes[0] = pmem[0];
    bytes[1] = pmem[1];

    return (val);
}

gives me

    B580        push {r7, lr}
    B081        sub sp, #4
    AF00        add r7, sp, #0
    1CBB        adds r3, r7, #2
    7802        ldrb r2, [r0, #0]
    701A        strb r2, [r3, #0]
    7842        ldrb r2, [r0, #1]
    8818        ldrh r0, [r3, #0]
    46BD        mov sp, r7
    B001        add sp, #4
    BC80        pop {r7}
    BC02        pop {r1}
    4708        bx r1

Which reads the second byte into r2 but does not store it on the stack, so the
second byte of val is returned uninitialized.
It looks like the alias analysis knows that bytes points to val but doesn't
know that bytes+1 points to a part of val also, so optimizes it away.

Yell out if you need any more information


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]