Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 34916
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Paulo Marques <pmarques@grupopie.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
xpr27364.c.162r.combine Combine pass RTL dump file text/plain 2008-01-22 00:23 1.44 KB Edit
xpr27364.c.161r.dce dce pass RTL dump file (bfore combine) text/plain 2008-01-22 00:26 2.26 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 34916 depends on: Show dependency tree
Show dependency graph
Bug 34916 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-04-04 22:34 Opened: 2008-01-21 23:55
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.

------- Comment #1 From Andy Hutchinson 2008-01-22 00:23 -------
Created an attachment (id=14991) [edit]
Combine pass RTL dump file

------- Comment #2 From Andy Hutchinson 2008-01-22 00:26 -------
Created an attachment (id=14992) [edit]
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). 

------- Comment #3 From Andy Hutchinson 2008-01-22 00:52 -------
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

------- Comment #4 From Andy Hutchinson 2008-01-22 23:41 -------
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

------- Comment #5 From Paulo Marques 2008-01-23 03:31 -------
I just found out another data point: this happens when you pass
-mmcu=atmega128, but not if you pass -mmcu=attiny13 (for instance).

------- Comment #6 From Manuel López-Ibáñez 2008-01-23 18:37 -------
Regressions should have a target milestone

------- Comment #7 From Joseph S. Myers 2008-03-15 00:42 -------
Update milestone after 4.3.0 release.

------- Comment #8 From Andy Hutchinson 2008-03-15 23:40 -------
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

------- Comment #9 From Andy Hutchinson 2008-04-04 23:46 -------
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

------- Comment #10 From Eric Weddington 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?

------- Comment #11 From Andy Hutchinson 2008-04-08 17:23 -------
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.

------- Comment #12 From Andy Hutchinson 2008-04-09 22:51 -------
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

------- Comment #13 From Andy Hutchinson 2008-04-12 15:38 -------
Fixed 4.3 and 4.4

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug