public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/43236]  New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
@ 2010-03-02 20:14 zsojka at seznam dot cz
  2010-03-02 20:21 ` [Bug tree-optimization/43236] " zsojka at seznam dot cz
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: zsojka at seznam dot cz @ 2010-03-02 20:14 UTC (permalink / raw)
  To: gcc-bugs

Tested revisions:
trunk r157161 - fail (fix for pr42640 doesn't help)
trunk r156598 - fail

It causes bootstrap comparison failure with BOOT_CFLAGS="-O2
-ftree-loop-distribution":
Comparing stages 2 and 3
warning: gcc/cc1plus-checksum.o differs
warning: gcc/cc1-checksum.o differs
Bootstrap comparison failure!
libiberty/sha1.o differs
make[2]: *** [compare] Error 1

sha1.o has different code from stage1 and stage2 compilers

For commands:
$ /mnt/sdb1/build-157161/stage1-gcc/cc1 -O2 sha1.i -fdump-final-insns=s1.dump
-quiet
$ /mnt/sdb1/build-157161/stage2-gcc/cc1 -O2 sha1.i -fdump-final-insns=s2.dump
-quiet
$ diff s[12].dump
7036a7037,7042                           
> (insn# 0 0 /mnt/svn/gcc-trunk/libiberty/sha1.c:401 (set (mem/s:SI (plus:DI (reg/f:DI 7 sp)
>                 (const_int 8 [0x8])) [3 x+32 S4 A256])                                    
>         (reg:SI 43 r14 [orig:989 D.4059 ] [989]))# {*movsi_1} (nil))                      
> (insn:TI# 0 0 /mnt/svn/gcc-trunk/libiberty/sha1.c:402 (set (mem/s:SI (plus:DI (reg/f:DI 7 sp)
>                 (const_int 12 [0xc])) [3 x+36 S4 A32])                                       
>         (reg:SI 42 r13 [orig:1001 D.4059 ] [1001]))# {*movsi_1} (nil))                       
7044,7049d7049                                                                  
< (insn:TI# 0 0 /mnt/svn/gcc-trunk/libiberty/sha1.c:401 (set (mem/s:SI (plus:DI
(reg/f:DI 7 sp)
....
(long output)

Diffs for gcc to assert on failure will be attached.


-- 
           Summary: -ftree-loop-distribution produces wrong code in
                    reload1.c:delete_output_reload(), bootstrap fails
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zsojka at seznam dot cz
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
@ 2010-03-02 20:21 ` zsojka at seznam dot cz
  2010-03-02 20:34 ` zsojka at seznam dot cz
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zsojka at seznam dot cz @ 2010-03-02 20:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from zsojka at seznam dot cz  2010-03-02 20:20 -------
Created an attachment (id=20005)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20005&action=view)
this patch causes bootstrap with BOOT_CFLAGS="-O2 -ftree-loop-distribution" to
assert

Assert message is:
/mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c: In function
&#8216;__mulvdi3&#8217;:
/mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c:400:1: internal compiler error: in
delete_output_reload, at reload1.c:8543
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

which is:
gcc_assert(spill_reg_store[last_reload_reg + k] == 0);


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
  2010-03-02 20:21 ` [Bug tree-optimization/43236] " zsojka at seznam dot cz
@ 2010-03-02 20:34 ` zsojka at seznam dot cz
  2010-03-03  6:27 ` zsojka at seznam dot cz
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zsojka at seznam dot cz @ 2010-03-02 20:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from zsojka at seznam dot cz  2010-03-02 20:33 -------
Created an attachment (id=20006)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20006&action=view)
this patch causes regular bootstrap to assert

Assert message is:
/mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c: In function
&#8216;__mulvdi3&#8217;:
/mnt/svn/gcc-trunk/libgcc/../gcc/libgcc2.c:400:1: internal compiler error: in
delete_output_reload, at reload1.c:8543
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

which is:
gcc_assert(spill_reg_store[last_reload_reg + k] == 0);


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
  2010-03-02 20:21 ` [Bug tree-optimization/43236] " zsojka at seznam dot cz
  2010-03-02 20:34 ` zsojka at seznam dot cz
@ 2010-03-03  6:27 ` zsojka at seznam dot cz
  2010-03-03  6:31 ` zsojka at seznam dot cz
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zsojka at seznam dot cz @ 2010-03-03  6:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from zsojka at seznam dot cz  2010-03-03 06:26 -------
Created an attachment (id=20008)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20008&action=view)
minimal executable testcase

Fails when compiled with -ftree-loop-distribution at all -O[123s] levels:
$ /mnt/svn/gcc-trunk/binary-157161/bin/gcc pr43236.c -O1
-ftree-loop-distribution && ./a.out
Aborted


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2010-03-03  6:27 ` zsojka at seznam dot cz
@ 2010-03-03  6:31 ` zsojka at seznam dot cz
  2010-03-03 10:38 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: zsojka at seznam dot cz @ 2010-03-03  6:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from zsojka at seznam dot cz  2010-03-03 06:30 -------
(In reply to comment #3)

When output is uncommented, -Os shows different behaviour than -O[123] (but
still wrong):
-Os zeroes items [8] - [18]
-O[123] zeroes [9] - [18]
expected is [10] - [19]


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2010-03-03  6:31 ` zsojka at seznam dot cz
@ 2010-03-03 10:38 ` rguenth at gcc dot gnu dot org
  2010-03-03 13:07 ` amonakov at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-03 10:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-03-03 10:38 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spop at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to fail|                            |4.4.3 4.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-03 10:38:17
               date|                            |


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2010-03-03 10:38 ` rguenth at gcc dot gnu dot org
@ 2010-03-03 13:07 ` amonakov at gcc dot gnu dot org
  2010-03-03 13:39 ` amonakov at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: amonakov at gcc dot gnu dot org @ 2010-03-03 13:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from amonakov at gcc dot gnu dot org  2010-03-03 13:06 -------
Not a regression, off-by-one error in reverse iteration case is since day one.
Patch:
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 13ac7ea..110abdc 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -285,6 +285,8 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
       addr_base = fold_convert_loc (loc, sizetype, addr_base);
       addr_base = size_binop_loc (loc, MINUS_EXPR, addr_base,
                                  fold_convert_loc (loc, sizetype, nb_bytes));
+      addr_base = size_binop_loc (loc, PLUS_EXPR, addr_base,
+                                 TYPE_SIZE_UNIT (TREE_TYPE (op0)));
       addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR,
                                   TREE_TYPE (DR_BASE_ADDRESS (dr)),
                                   DR_BASE_ADDRESS (dr), addr_base);

This fixes the -O[123] miscompilations. -Os is slightly harder to fix, since we
use wrong number of iterations (cond bb is executed 11 times, latch bb with
assignment 10 times).


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2010-03-03 13:07 ` amonakov at gcc dot gnu dot org
@ 2010-03-03 13:39 ` amonakov at gcc dot gnu dot org
  2010-03-09 16:56 ` amonakov at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: amonakov at gcc dot gnu dot org @ 2010-03-03 13:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from amonakov at gcc dot gnu dot org  2010-03-03 13:38 -------
(In reply to comment #6)
> This fixes the -O[123] miscompilations. -Os is slightly harder to fix, since we
> use wrong number of iterations (cond bb is executed 11 times, latch bb with
> assignment 10 times).

I don't see what is the proper fix for the -Os problem.  The loop structure is
as follows:
<bb2>
i = 20
goto bb4

 <bb3>
  i--
  a[i] = 0
 <bb4>
  if (i > 10) goto bb3
Thus, bb4 is header, bb3 is latch, number_of_exit_cond_executions() is 11,
just_once_each_iteration_p() is true for both bb3 and bb4 (?!)


-- 

amonakov at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amonakov at gcc dot gnu dot
                   |                            |org


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2010-03-03 13:39 ` amonakov at gcc dot gnu dot org
@ 2010-03-09 16:56 ` amonakov at gcc dot gnu dot org
  2010-03-10 12:54 ` amonakov at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: amonakov at gcc dot gnu dot org @ 2010-03-09 16:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from amonakov at gcc dot gnu dot org  2010-03-09 16:55 -------
Given the fact that loop distribution only works for two-bb loops, I think the
fix is to simply take number of latch executions when the stmt is in the latch.

diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -389,6 +391,8 @@ generate_builtin (struct loop *loop, bitmap partition, bool
copy_p)
                goto end;

              write = stmt;
+             if (bb == loop->latch)
+               nb_iter = number_of_latch_executions (loop);
            }
        }
     }


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2010-03-09 16:56 ` amonakov at gcc dot gnu dot org
@ 2010-03-10 12:54 ` amonakov at gcc dot gnu dot org
  2010-03-10 12:57 ` amonakov at gcc dot gnu dot org
  2010-03-10 14:17 ` sezeroz at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: amonakov at gcc dot gnu dot org @ 2010-03-10 12:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from amonakov at gcc dot gnu dot org  2010-03-10 12:54 -------
Subject: Bug 43236

Author: amonakov
Date: Wed Mar 10 12:53:51 2010
New Revision: 157339

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157339
Log:
        PR tree-optimization/43236
        * tree-loop-distribution.c (generate_memset_zero): Fix off-by-one
        error in calculation of base address in reverse iteration case.
        (generate_builtin): Take number of latch executions if the statement
        is in the latch.

        * gcc.c-torture/execute/pr43236.c: New.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr43236.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-loop-distribution.c


-- 


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (8 preceding siblings ...)
  2010-03-10 12:54 ` amonakov at gcc dot gnu dot org
@ 2010-03-10 12:57 ` amonakov at gcc dot gnu dot org
  2010-03-10 14:17 ` sezeroz at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: amonakov at gcc dot gnu dot org @ 2010-03-10 12:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from amonakov at gcc dot gnu dot org  2010-03-10 12:57 -------
Both issues are fixed with above commit.


-- 

amonakov at gcc dot gnu dot org changed:

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


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


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

* [Bug tree-optimization/43236] -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails
  2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
                   ` (9 preceding siblings ...)
  2010-03-10 12:57 ` amonakov at gcc dot gnu dot org
@ 2010-03-10 14:17 ` sezeroz at gmail dot com
  10 siblings, 0 replies; 12+ messages in thread
From: sezeroz at gmail dot com @ 2010-03-10 14:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from sezeroz at gmail dot com  2010-03-10 14:17 -------
The testcase fails with 4.4 with -Ox -ftree-loop-distribution and the patch
does not apply to 4.4. Will there be a gcc-4.4 backport of this?


-- 

sezeroz at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sezeroz at gmail dot com


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


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

end of thread, other threads:[~2010-03-10 14:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-02 20:14 [Bug tree-optimization/43236] New: -ftree-loop-distribution produces wrong code in reload1.c:delete_output_reload(), bootstrap fails zsojka at seznam dot cz
2010-03-02 20:21 ` [Bug tree-optimization/43236] " zsojka at seznam dot cz
2010-03-02 20:34 ` zsojka at seznam dot cz
2010-03-03  6:27 ` zsojka at seznam dot cz
2010-03-03  6:31 ` zsojka at seznam dot cz
2010-03-03 10:38 ` rguenth at gcc dot gnu dot org
2010-03-03 13:07 ` amonakov at gcc dot gnu dot org
2010-03-03 13:39 ` amonakov at gcc dot gnu dot org
2010-03-09 16:56 ` amonakov at gcc dot gnu dot org
2010-03-10 12:54 ` amonakov at gcc dot gnu dot org
2010-03-10 12:57 ` amonakov at gcc dot gnu dot org
2010-03-10 14:17 ` sezeroz at gmail dot com

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).