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 c/29907] New: ARM Optimization Bug


The code below generates invalid assembler code:

typedef struct Chain_Node_struct Chain_Node;

struct Chain_Node_struct {
  Chain_Node *next;
  Chain_Node *previous;
};

typedef struct {
   Chain_Node *first;
   Chain_Node *permanent_null;
   Chain_Node *last;
} Chain_Control;

extern Chain_Control *rdy;

void func(Chain_Node *a )
{
   if( rdy->first != rdy->last )
   {
     Chain_Node *next;
     Chain_Node *previous;
     Chain_Node *old_last_node;

      next           = a->next;
      previous       = a->previous;
      next->previous = previous;
      previous->next = next;

    a->next             = (Chain_Node*)&rdy->permanent_null;
    old_last_node       = rdy->last;
    rdy->last           = a;
    old_last_node->next = a;
    a->previous         = old_last_node;
   }
}


00000000 <func>:
   0:   e59f3038        ldr     r3, [pc, #56]   ; 40 <.text+0x40>
   4:   e5931000        ldr     r1, [r3]
   8:   e591c008        ldr     ip, [r1, #8] ; here ip is loaded
   c:   e5913000        ldr     r3, [r1]
  10:   e153000c        cmp     r3, ip
  14:   e52de004        str     lr, [sp, #-4]!
  18:   e281e004        add     lr, r1, #4      ; 0x4
  1c:   049df004        ldreq   pc, [sp], #4
  20:   e890000c        ldmia   r0, {r2, r3}
  24:   e5832000        str     r2, [r3]
  28:   e5823004        str     r3, [r2, #4]
  2c:   e580e000        str     lr, [r0]
  30:   e5810008        str     r0, [r1, #8]
  34:   e580c004        str     ip, [r0, #4] ; you can see that ip register
consists value which does not correspond to [r1, #8] at steps between 2c and 30
  38:   e58c0000        str     r0, [ip]
  3c:   e49df004        ldr     pc, [sp], #4
  40:   00000000        andeq   r0, r0, r0


-- 
           Summary: ARM Optimization Bug
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wad at infinet dot ru
 GCC build triplet: arm-rtems-gcc -O2 -g -c test.c
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: arm-rtems


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


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