public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc
@ 2004-01-27  7:37 debian-gcc at lists dot debian dot org
  2004-01-27  7:38 ` [Bug target/13877] " debian-gcc at lists dot debian dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2004-01-27  7:37 UTC (permalink / raw)
  To: gcc-bugs

[forwarded from http://bugs.debian.org/229567]

seen with 3.3 CVS 20040110, not in 3.2.3 and 3.4 CVS.

When complied with -O -funroll-loops on powerpc, the attached test.i 
produces the following output: 
 
Bytes in main:  0 1 
Bytes in: 0 1 0 1 0 1 ( 0 10 15 254) 
x = 282 
Bytes in: 0 1 0 1 0 1 ( 94 52 15 254) 
x = 418 
Bytes in: 0 1 0 1 0 1 ( 7 208 15 254) 
x = 487 
 
The reported x's should be the sum of the first six numbers on the line 
above. Instead, it is the sum of _all_ the numbers on the line above. 
Changing -O to -O2, or removing -funroll-loops generates the following 
(correct) result: 

Bytes in main:  0 1 
Bytes in: 0 1 0 1 0 1 ( 70 148 15 234) 
x = 3 
Bytes in: 0 1 0 1 0 1 ( 0 10 15 254) 
x = 3 
Bytes in: 0 1 0 1 0 1 ( 7 76 15 234) 
x = 3 
 
On 386, this problem does not occur. 
 
Note that this could be the same bug as PR13222, in which case this would 
be a nice, small, test case. I have not actually looked at the test case 
in PR13222 however, since it is rather large. 
 
Flags used: 
  gcc -O -funroll-loops test.i

-- 
           Summary: [3.3 regression] miscompilation with -O -funroll-loops
                    on powerpc
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: debian-gcc at lists dot debian dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-linux
  GCC host triplet: powerpc-linux
GCC target triplet: powerpc-linux


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
@ 2004-01-27  7:38 ` debian-gcc at lists dot debian dot org
  2004-01-27  7:44 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2004-01-27  7:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From debian-gcc at lists dot debian dot org  2004-01-27 07:38 -------
Created an attachment (id=5590)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5590&action=view)
preprocessed source


-- 


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
  2004-01-27  7:38 ` [Bug target/13877] " debian-gcc at lists dot debian dot org
@ 2004-01-27  7:44 ` pinskia at gcc dot gnu dot org
  2004-01-27  8:25 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-27  7:44 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #5590|application/octet-stream    |text/plain
          mime type|                            |


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
  2004-01-27  7:38 ` [Bug target/13877] " debian-gcc at lists dot debian dot org
  2004-01-27  7:44 ` pinskia at gcc dot gnu dot org
@ 2004-01-27  8:25 ` pinskia at gcc dot gnu dot org
  2004-02-15 12:41 ` gdr at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-27  8:25 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to fail|                            |3.3.3
      Known to work|                            |3.2.3 3.4.0 3.5.0
   Target Milestone|---                         |3.3.3


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (2 preceding siblings ...)
  2004-01-27  8:25 ` pinskia at gcc dot gnu dot org
@ 2004-02-15 12:41 ` gdr at gcc dot gnu dot org
  2004-03-05 11:38 ` gdr at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-02-15 12:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-02-15 12:41 -------
Adjust milestone

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.3.3                       |3.3.4


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (3 preceding siblings ...)
  2004-02-15 12:41 ` gdr at gcc dot gnu dot org
@ 2004-03-05 11:38 ` gdr at gcc dot gnu dot org
  2004-03-05 22:08 ` doko at cs dot tu-berlin dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-03-05 11:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-03-05 11:38 -------
This is UNCONFIRMED and critical, what is going on?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (4 preceding siblings ...)
  2004-03-05 11:38 ` gdr at gcc dot gnu dot org
@ 2004-03-05 22:08 ` doko at cs dot tu-berlin dot de
  2004-03-10 23:43 ` wilson at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: doko at cs dot tu-berlin dot de @ 2004-03-05 22:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From doko at cs dot tu-berlin dot de  2004-03-05 22:08 -------
Subject: Re:  [3.3 regression] miscompilation with -O -funroll-loops on powerpc

gdr at gcc dot gnu dot org writes:
> 
> ------- Additional Comments From gdr at gcc dot gnu dot org  2004-03-05 11:38 -------
> This is UNCONFIRMED and critical, what is going on?

it's my understanding that the severity is independent from the
status. I'll recheck with 3.3.3.

	Matthias


-- 


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (5 preceding siblings ...)
  2004-03-05 22:08 ` doko at cs dot tu-berlin dot de
@ 2004-03-10 23:43 ` wilson at gcc dot gnu dot org
  2004-03-13  1:19 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wilson at gcc dot gnu dot org @ 2004-03-10 23:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From wilson at gcc dot gnu dot org  2004-03-10 23:43 -------
I can reproduce the problem with gcc-3_3-branch on powerpc-darwin.  I can also
reproduce the problem with current sources using -O -fold-unroll-loops.

The problem is a bad interaction between the old loop unroller and doloop.  The
loop in question executes 6 times.  The initial value of the iterator is 0.  The
final value is pseudo-reg 118 which holds the value 6 at run time.  The old loop
unrolling preconditions the loop and then unrolls it four times.  Now, at the
LOOP_BEG note, the initial value is now 2 at runtime, or (mod (reg 118)
(const_int 4)).  The loop_info->initial_value field is not changed.

Then doloop_optimize runs, and tries to do some of the same calculations as
unroll.c.  It decides that the loop will run (reg 118) times (i.e. 6 times),
because that is final_value minus the initial_value.  It sees that the loop
increments the iterator by 4 each loop iteration, and thus the loop must execute
ceil (r118 / 4) * 4, which at run time means 8.  And now we are hosed, as doloop
proceeds to make incorrect transformations based on the 8 number.

One possible way to fix this is to clear loop_info->initial_value after
preconditioning the loop, to indicate that the initial value is now unknown. 
This disables the doloop optimization, avoiding the bug.  Putting the (mod...)
expression here seems less useful, as that might confuse other loop optimizers.

An even better solution would be to pass enough info from unroll_loops to
do_loop_optimize so that the optimization can still occur.  I haven't looked at
how to do this.

This problem does not occur with the new loop unroller because it is a separate
pass from loop.c, and does not use the loop_info structure.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-10 23:43:10
               date|                            |


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (6 preceding siblings ...)
  2004-03-10 23:43 ` wilson at gcc dot gnu dot org
@ 2004-03-13  1:19 ` cvs-commit at gcc dot gnu dot org
  2004-03-13  1:20 ` gdr at gcc dot gnu dot org
  2004-03-13  7:04 ` debian-gcc at lists dot debian dot org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-03-13  1:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-03-13 01:19 -------
Subject: Bug 13877

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	gdr@gcc.gnu.org	2004-03-13 01:19:05

Modified files:
	gcc            : ChangeLog unroll.c 

Log message:
	PR target/13877
	* unroll.c (unroll_loop): If precondition loop, clear the
	initial_value
	field in loop_info.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.937&r2=1.16114.2.938
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/unroll.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.184.2.7&r2=1.184.2.8



-- 


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (7 preceding siblings ...)
  2004-03-13  1:19 ` cvs-commit at gcc dot gnu dot org
@ 2004-03-13  1:20 ` gdr at gcc dot gnu dot org
  2004-03-13  7:04 ` debian-gcc at lists dot debian dot org
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-03-13  1:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-03-13 01:20 -------
(In reply to comment #6)
> Created an attachment (id=5894)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5894&action=view)
> clear loop_info->initial_value is loop preconditioned
> 
> This fixes the problem by disabling doloop when it would interfere with loop
> unrolling.  This works for the testcase, but otherwise has not been tested.

Thanks for the patch.  Tested and applied.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug target/13877] [3.3 regression] miscompilation with -O -funroll-loops on powerpc
  2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
                   ` (8 preceding siblings ...)
  2004-03-13  1:20 ` gdr at gcc dot gnu dot org
@ 2004-03-13  7:04 ` debian-gcc at lists dot debian dot org
  9 siblings, 0 replies; 11+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2004-03-13  7:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From debian-gcc at lists dot debian dot org  2004-03-13 07:04 -------
Compared to CVS 20040306 I see the following new regressions on powerpc-linux, I
don't know if the last build was made on a faster machine.

+WARNING: program timed out.
+FAIL: gcc.c-torture/compile/20001226-1.c,  -O3 -g  
+WARNING: program timed out.
+FAIL: gcc.c-torture/compile/20001226-1.c,  -Os  

+WARNING: program timed out.
+FAIL: 27_io/filebuf_members.cc execution test

-- 


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


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

end of thread, other threads:[~2004-03-13  7:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-27  7:37 [Bug target/13877] New: [3.3 regression] miscompilation with -O -funroll-loops on powerpc debian-gcc at lists dot debian dot org
2004-01-27  7:38 ` [Bug target/13877] " debian-gcc at lists dot debian dot org
2004-01-27  7:44 ` pinskia at gcc dot gnu dot org
2004-01-27  8:25 ` pinskia at gcc dot gnu dot org
2004-02-15 12:41 ` gdr at gcc dot gnu dot org
2004-03-05 11:38 ` gdr at gcc dot gnu dot org
2004-03-05 22:08 ` doko at cs dot tu-berlin dot de
2004-03-10 23:43 ` wilson at gcc dot gnu dot org
2004-03-13  1:19 ` cvs-commit at gcc dot gnu dot org
2004-03-13  1:20 ` gdr at gcc dot gnu dot org
2004-03-13  7:04 ` debian-gcc at lists dot debian dot 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).