This test case fails with latest gcc 4.3.0. The test assumes 32 bit integers, but even after changing the constants to long, it produces incorrect results. With -O2 we get this: int f(unsigned number_of_digits_to_use) { if (number_of_digits_to_use > 1294) 206: 65 e0 ldi r22, 0x05 ; 5 208: 8f 30 cpi r24, 0x0F ; 15 20a: 96 07 cpc r25, r22 20c: c0 f4 brcc .+48 ; 0x23e <f+0x38> return 0; return ((number_of_digits_to_use * 3321928L) / 1000000L + 1) /16; 20e: bc 01 movw r22, r24 210: 80 e0 ldi r24, 0x00 ; 0 212: 90 e0 ldi r25, 0x00 ; 0 214: 0e 94 6c 06 call 0xcd8 ; 0xcd8 <__mulsi3> [...] It "forgets" to load r18:r19:r20:r21 with 3321928 before calling __mulsi3.
Created attachment 14991 [details] Combine pass RTL dump file
Created attachment 14992 [details] dce pass RTL dump file (bfore combine) Posted two RTL dump file of smaller testcase: long f2(long number_of_digits_to_use) { return ( number_of_digits_to_use * 11L ) ; } This faile GCC head 4.3.0 of 13/12/2007 Combine decide load of constant is not needed. Seem to happen after combine tries combining load with multiply (ie multiply by constant).
Assembler of short testcase. Constant load (11L) missing 16 .Ltext0: 17 .global f2 19 f2: 20 .LFB2: 21 .LM1: 22 .LVL0: 23 /* prologue: function */ 24 /* frame size = 0 */ 25 .LM2: 26 0000 0E94 0000 call __mulsi3 27 .LVL1: 28 /* epilogue start */ 29 .LM3: 30 0004 0895 ret 31 .LFE2: 57 .Letext0: DEFINED SYMBOLS
The WRONG CODE is still present on 4.3.0 20080121 HEAD. This is a regresssion from 4.2 (A big one too!) 4.2.2 20071221 (Winavr) OK 4.3.0 20071213 FAILS 4.3.0 HEAD 20080121 FAILS vr-gcc -c -mmcu=atmega128 -g -w -Q -O2 -DSTACK_SIZE=400 -da -DNO_TRAMPOLINES -fno-show-column -DSIGNAL_SUPPRESS -lm -Wa,-adhlns=xpr27364.lst -lm -std=gnu99 xpr27364.c -o xpr27364.o
I just found out another data point: this happens when you pass -mmcu=atmega128, but not if you pass -mmcu=attiny13 (for instance).
Regressions should have a target milestone
Update milestone after 4.3.0 release.
This appear to be same bug where combine is erroneously assuming all DF register references are to different instructions. So it tries combining instructions with themselves and stuff gets lost. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35519 The above testcase still fails with gcc version 4.4.0 20080305. However, with patch from PR35519 it produces correct code: 23 /* prologue: function */ 24 /* frame size = 0 */ 25 .LM2: 26 0000 2BE0 ldi r18,lo8(11) 27 0002 30E0 ldi r19,hi8(11) 28 0004 40E0 ldi r20,hlo8(11) 29 0006 50E0 ldi r21,hhi8(11) 30 0008 0E94 0000 call __mulsi3 31 .LVL1: 32 /* epilogue start */ 33 .LM3: 34 000c 0895 ret
Subject: Bug 34916 Author: hutchinsonandy Date: Fri Apr 4 23:45:46 2008 New Revision: 133920 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133920 Log: PR rtl-optimization/34916 PR middle-end/35519 * combine.c (create_log_links): Do not create duplicate LOG_LINKS between instruction pairs Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c
Andy, since this was a 4.3 regression is there any way we can back port this and commit it on the 4.3 branch?
Subject: Re: [4.3/4.4 Regression] gcc.c-torture/execute/pr27364.c fails with -O1, -O2 and -Os I believe the rules allow for this after a suitable grace period. Remind me towards end of week and I will post for approval. Andy -----Original Message----- From: eric dot weddington at atmel dot com <gcc-bugzilla@gcc.gnu.org> To: hutchinsonandy@aim.com Sent: Tue, 8 Apr 2008 11:16 am Subject: [Bug target/34916] [4.3/4.4 Regression] gcc.c-torture/execute/pr27364.c fails with -O1, -O2 and -Os ------- Comment #10 from eric dot weddington at atmel dot com 2008-04-08 15:16 ------- Andy, since this was a 4.3 regression is there any way we can back port this and commit it on the 4.3 branch? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34916 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
Subject: Bug 34916 Author: hutchinsonandy Date: Wed Apr 9 22:50:42 2008 New Revision: 134152 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134152 Log: 2008-04-09 Andy Hutchinson <hutchinsonandy@aim.com> PR rtl-optimization/34916 PR middle-end/35519 * combine.c (create_log_links): Do not create duplicate LOG_LINKS between instruction pairs Modified: branches/gcc-4_3-branch/gcc/ChangeLog branches/gcc-4_3-branch/gcc/combine.c
Fixed 4.3 and 4.4