public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/50063] New: [avr]: wrong code for gcc.dg/torture/pta-ptrarith-3.c
@ 2011-08-12 20:26 gjl at gcc dot gnu.org
  2011-08-12 20:46 ` [Bug target/50063] " gjl at gcc dot gnu.org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-08-12 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50063
           Summary: [avr]: wrong code for gcc.dg/torture/pta-ptrarith-3.c
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gjl@gcc.gnu.org
                CC: eric.weddington@atmel.com
            Target: avr


Testcase gcc.dg/torture/pta-ptrarith-3.c
  
http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c?revision=145490&view=markup
produces wrong code for current trunk and avr-gcc 4.6.1

struct X 
{
  int *p;
  int *q;
  int *r;
};

int __attribute__((noinline))
foo (int i, int j, int k, int off)
{
  struct X x;
  int **p, *q;
  x.p = &i;
  x.q = &j;
  x.r = &k;
  p = &x.q;
  p += off;
  /* *p points to { i, j, k } */
  q = *p;
  return *q;
}

With -Os -mmcu=atmega88 4.6.1 output is (wrong):

foo:
    push r28     ;  42    *pushqi/1    [length = 1]
    push r29     ;  43    *pushqi/1    [length = 1]
    in r28,__SP_L__     ;  44    *movhi_sp/2    [length = 2]
    in r29,__SP_H__
    sbiw r28,12     ;  45    *addhi3/3    [length = 1]
    in __tmp_reg__,__SREG__     ;  46    *movhi_sp/1    [length = 5]
    cli
    out __SP_H__,r29
    out __SREG__,__tmp_reg__
    out __SP_L__,r28
/* prologue: function */
/* frame size = 12 */
/* stack size = 14 */
.L__stack_usage = 14
    std Y+8,r25     ;  2    *movhi/3    [length = 2]
    std Y+7,r24
    std Y+10,r23     ;  3    *movhi/3    [length = 2]
    std Y+9,r22
    std Y+12,r21     ;  4    *movhi/3    [length = 2]
    std Y+11,r20
    lsl r18     ;  55    *ashlhi3_const/2    [length = 2]
    rol r19
    add r18,r28     ;  16    *addhi3/1    [length = 2]
    adc r19,r29
    movw r26,r18     ;  41    *movhi/1    [length = 1]
    adiw r26,3     ;  18    *movhi/2    [length = 4]
    ld r30,X+
    ld r31,X
    sbiw r26,3+1
    ld r24,Z     ;  35    *movqi/4    [length = 1]
    ldd r25,Z+1     ;  36    *movqi/4    [length = 1]
/* epilogue start */
    adiw r28,12     ;  49    *addhi3/2    [length = 1]
    in __tmp_reg__,__SREG__     ;  50    *movhi_sp/1    [length = 5]
    cli
    out __SP_H__,r29
    out __SREG__,__tmp_reg__
    out __SP_L__,r28
    pop r29     ;  51    popqi    [length = 1]
    pop r28     ;  52    popqi    [length = 1]
    ret     ;  53    return_from_epilogue    [length = 1]



With 4.5.2 and same options, the test case runs on exit:


foo:
    push r29     ;  42    *pushhi/1    [length = 2]
    push r28
    in r28,__SP_L__     ;  43    *movhi_sp/2    [length = 2]
    in r29,__SP_H__
    sbiw r28,12     ;  44    *addhi3/3    [length = 1]
    in __tmp_reg__,__SREG__     ;  45    *movhi_sp/1    [length = 5]
    cli
    out __SP_H__,r29
    out __SREG__,__tmp_reg__
    out __SP_L__,r28
/* prologue: function */
/* frame size = 12 */
/* stack size = 14 */
.L__stack_usage = 14
    std Y+8,r25     ;  2    *movhi/3    [length = 2]
    std Y+7,r24
    std Y+10,r23     ;  3    *movhi/3    [length = 2]
    std Y+9,r22
    std Y+12,r21     ;  4    *movhi/3    [length = 2]
    std Y+11,r20
    movw r24,r28     ;  38    *movhi/1    [length = 1]
    adiw r24,7     ;  9    *addhi3/2    [length = 1]
    std Y+2,r25     ;  10    *movhi/3    [length = 2]
    std Y+1,r24
    movw r24,r28     ;  39    *movhi/1    [length = 1]
    adiw r24,9     ;  11    *addhi3/2    [length = 1]
    std Y+4,r25     ;  12    *movhi/3    [length = 2]
    std Y+3,r24
    movw r24,r28     ;  40    *movhi/1    [length = 1]
    adiw r24,11     ;  13    *addhi3/2    [length = 1]
    std Y+6,r25     ;  14    *movhi/3    [length = 2]
    std Y+5,r24
    lsl r18     ;  53    *ashlhi3_const/2    [length = 2]
    rol r19
    add r18,r28     ;  16    *addhi3/1    [length = 2]
    adc r19,r29
    movw r26,r18     ;  41    *movhi/1    [length = 1]
    adiw r26,3     ;  18    *movhi/2    [length = 4]
    ld r30,X+
    ld r31,X
    sbiw r26,3+1
    ld r24,Z     ;  35    *movqi/4    [length = 1]
    ldd r25,Z+1     ;  36    *movqi/4    [length = 1]
/* epilogue start */
    adiw r28,12     ;  48    *addhi3/2    [length = 1]
    in __tmp_reg__,__SREG__     ;  49    *movhi_sp/1    [length = 5]
    cli
    out __SP_H__,r29
    out __SREG__,__tmp_reg__
    out __SP_L__,r28
    pop r28     ;  50    pophi    [length = 2]
    pop r29
    ret     ;  51    return_from_epilogue    [length = 1]


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-03-22 16:11 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-12 20:26 [Bug target/50063] New: [avr]: wrong code for gcc.dg/torture/pta-ptrarith-3.c gjl at gcc dot gnu.org
2011-08-12 20:46 ` [Bug target/50063] " gjl at gcc dot gnu.org
2011-08-13 17:06 ` gjl at gcc dot gnu.org
2011-08-13 17:10 ` gjl at gcc dot gnu.org
2011-08-13 17:33 ` [Bug rtl-optimization/50063] [avr]: DSE: " gjl at gcc dot gnu.org
2011-08-14  9:54 ` [Bug rtl-optimization/50063] [4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-08-15  8:09 ` gjl at gcc dot gnu.org
2011-08-15 11:06 ` rguenth at gcc dot gnu.org
2011-09-11 15:32 ` steven at gcc dot gnu.org
2011-09-11 15:48 ` steven at gcc dot gnu.org
2011-10-26 17:45 ` jakub at gcc dot gnu.org
2011-10-27 10:08 ` rguenth at gcc dot gnu.org
2011-12-19 18:39 ` jakub at gcc dot gnu.org
2011-12-19 18:58 ` gjl at gcc dot gnu.org
2011-12-19 19:16 ` jakub at gcc dot gnu.org
2011-12-19 23:25 ` gjl at gcc dot gnu.org
2011-12-20  0:31 ` jakub at gcc dot gnu.org
2011-12-20  7:34 ` jakub at gcc dot gnu.org
2011-12-22  0:21 ` gjl at gcc dot gnu.org
2012-02-20 13:55 ` gjl at gcc dot gnu.org
2012-02-20 14:17 ` jakub at gcc dot gnu.org
2012-02-22  9:32 ` gjl at gcc dot gnu.org
2012-03-01 15:04 ` jakub at gcc dot gnu.org
2012-03-22 16:22 ` [Bug rtl-optimization/50063] [4.6/4.7/4.8 " gjl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).