From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8090 invoked by alias); 12 Aug 2011 20:16:07 -0000 Received: (qmail 8065 invoked by uid 22791); 12 Aug 2011 20:16:02 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_OV,TW_PQ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Aug 2011 20:15:49 +0000 From: "gjl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/50063] New: [avr]: wrong code for gcc.dg/torture/pta-ptrarith-3.c Date: Fri, 12 Aug 2011 20:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gjl at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg01195.txt.bz2 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]