public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels
@ 2011-01-12 15:48 d.g.gorbachev at gmail dot com
  2011-01-13 10:56 ` [Bug rtl-optimization/47270] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-01-12 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [4.4/4.5/4.6 Regression] GCC produces
                    unnecessary/wrong code on -O2 and -O3 levels
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: d.g.gorbachev@gmail.com
              Host: i686-pc-linux-gnu
            Target: i686-pc-linux-gnu
             Build: i686-pc-linux-gnu


$ cat > testcase.c
register int r asm("esi");

void foo(void)
{
    if (r)
        __asm__("sar\t%0" : "+r" (r));

    __asm__("sar\t%0" : "+r" (r));
}
^D
$ gcc -O2 -S testcase.c
$ cat testcase.s
[...]
foo:
.LFB0:
        xorl    %eax, %eax
        testl   %esi, %esi
        je      .L2
#APP
# 6 "testcase.c" 1
        sar     %esi
# 0 "" 2
#NO_APP
        movl    %esi, %eax
.L2:
        movl    %eax, %esi
#APP
# 8 "testcase.c" 1
        sar     %esi
# 0 "" 2
#NO_APP
        ret
[...]


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

* [Bug rtl-optimization/47270] [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
@ 2011-01-13 10:56 ` rguenth at gcc dot gnu.org
  2011-01-17 12:37 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-13 10:56 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.4.6


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

* [Bug rtl-optimization/47270] [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
  2011-01-13 10:56 ` [Bug rtl-optimization/47270] " rguenth at gcc dot gnu.org
@ 2011-01-17 12:37 ` jakub at gcc dot gnu.org
  2011-01-26 18:21 ` [Bug rtl-optimization/47270] [4.4/4.5/4.6 Regression] GCC produces unnecessary " d.g.gorbachev at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-17 12:37 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-17 12:06:11 UTC ---
Why do you think it is wrong?  If %esi is non-zero upon entry, then it is just
moved to %eax and back, so it isn't changed, if it was zero upon entry, then 0
is loaded into it.
The reason for the extra code is that pre attempts to optimize it (register
vars are not SSA vars), so we get at *.optimized:
  int prephitmp.4;
  int r.0;

<bb 2>:
  r.0_1 = r;
  if (r.0_1 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  __asm__("sar  %0" : "=r" r : "0" r.0_1);
  prephitmp.4_2 = r;

<bb 4>:
  # prephitmp.4_8 = PHI <0(2), prephitmp.4_2(3)>
  __asm__("sar  %0" : "=r" r : "0" prephitmp.4_8);
and RTL optimizations aren't able to undo that.  I doubt anything can be done
about this easily, with -fno-tree-pre you get your expected output.


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

* [Bug rtl-optimization/47270] [4.4/4.5/4.6 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
  2011-01-13 10:56 ` [Bug rtl-optimization/47270] " rguenth at gcc dot gnu.org
  2011-01-17 12:37 ` jakub at gcc dot gnu.org
@ 2011-01-26 18:21 ` d.g.gorbachev at gmail dot com
  2011-04-16 10:30 ` [Bug rtl-optimization/47270] [4.4/4.5/4.6/4.7 " jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2011-01-26 18:21 UTC (permalink / raw)
  To: gcc-bugs

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

Dmitry Gorbachev <d.g.gorbachev at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
            Summary|[4.4/4.5/4.6 Regression]    |[4.4/4.5/4.6 Regression]
                   |GCC produces                |GCC produces unnecessary
                   |unnecessary/wrong code on   |code on -O2 and -O3 levels
                   |-O2 and -O3 levels          |

--- Comment #2 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2011-01-26 18:03:33 UTC ---
Ah, yes; changed the summary.


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

* [Bug rtl-optimization/47270] [4.4/4.5/4.6/4.7 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (2 preceding siblings ...)
  2011-01-26 18:21 ` [Bug rtl-optimization/47270] [4.4/4.5/4.6 Regression] GCC produces unnecessary " d.g.gorbachev at gmail dot com
@ 2011-04-16 10:30 ` jakub at gcc dot gnu.org
  2012-03-13 14:54 ` [Bug rtl-optimization/47270] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-16 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.4.6                       |4.4.7


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

* [Bug rtl-optimization/47270] [4.5/4.6/4.7/4.8 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (3 preceding siblings ...)
  2011-04-16 10:30 ` [Bug rtl-optimization/47270] [4.4/4.5/4.6/4.7 " jakub at gcc dot gnu.org
@ 2012-03-13 14:54 ` jakub at gcc dot gnu.org
  2012-07-02 13:13 ` [Bug rtl-optimization/47270] [4.6/4.7/4.8 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-13 14:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.4.7                       |4.5.4

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-13 12:47:27 UTC ---
4.4 branch is being closed, moving to 4.5.4 target.


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

* [Bug rtl-optimization/47270] [4.6/4.7/4.8 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (4 preceding siblings ...)
  2012-03-13 14:54 ` [Bug rtl-optimization/47270] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
@ 2012-07-02 13:13 ` rguenth at gcc dot gnu.org
  2013-03-05 23:29 ` steven at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-02 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.5.4                       |4.6.4


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

* [Bug rtl-optimization/47270] [4.6/4.7/4.8 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (5 preceding siblings ...)
  2012-07-02 13:13 ` [Bug rtl-optimization/47270] [4.6/4.7/4.8 " rguenth at gcc dot gnu.org
@ 2013-03-05 23:29 ` steven at gcc dot gnu.org
  2013-04-12 15:18 ` [Bug rtl-optimization/47270] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2013-03-05 23:29 UTC (permalink / raw)
  To: gcc-bugs


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

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-03-05
     Ever Confirmed|0                           |1

--- Comment #4 from Steven Bosscher <steven at gcc dot gnu.org> 2013-03-05 23:28:58 UTC ---
(In reply to comment #1)
> and RTL optimizations aren't able to undo that.  I doubt anything can
> be done about this easily.

Perhaps tree-ssa-uncprop should handle this.

FWIW, I've always thought that constant propagation into PHI arguments
was a mistake...


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

* [Bug rtl-optimization/47270] [4.7/4.8/4.9 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (6 preceding siblings ...)
  2013-03-05 23:29 ` steven at gcc dot gnu.org
@ 2013-04-12 15:18 ` jakub at gcc dot gnu.org
  2013-04-12 20:34 ` d.g.gorbachev at gmail dot com
  2013-12-25  0:00 ` steven at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-12 15:18 UTC (permalink / raw)
  To: gcc-bugs


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.6.4                       |4.7.4

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-12 15:16:51 UTC ---
GCC 4.6.4 has been released and the branch has been closed.


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

* [Bug rtl-optimization/47270] [4.7/4.8/4.9 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (7 preceding siblings ...)
  2013-04-12 15:18 ` [Bug rtl-optimization/47270] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
@ 2013-04-12 20:34 ` d.g.gorbachev at gmail dot com
  2013-12-25  0:00 ` steven at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: d.g.gorbachev at gmail dot com @ 2013-04-12 20:34 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Dmitry Gorbachev <d.g.gorbachev at gmail dot com> 2013-04-12 20:34:31 UTC ---
I can't reproduce the bug with GCC 4.7.3 and 4.8.1.


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

* [Bug rtl-optimization/47270] [4.7/4.8/4.9 Regression] GCC produces unnecessary code on -O2 and -O3 levels
  2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
                   ` (8 preceding siblings ...)
  2013-04-12 20:34 ` d.g.gorbachev at gmail dot com
@ 2013-12-25  0:00 ` steven at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2013-12-25  0:00 UTC (permalink / raw)
  To: gcc-bugs

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

Steven Bosscher <steven at gcc dot gnu.org> changed:

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

--- Comment #7 from Steven Bosscher <steven at gcc dot gnu.org> ---
Apparently fixed (probably by IRA).


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

end of thread, other threads:[~2013-12-25  0:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-12 15:48 [Bug rtl-optimization/47270] New: [4.4/4.5/4.6 Regression] GCC produces unnecessary/wrong code on -O2 and -O3 levels d.g.gorbachev at gmail dot com
2011-01-13 10:56 ` [Bug rtl-optimization/47270] " rguenth at gcc dot gnu.org
2011-01-17 12:37 ` jakub at gcc dot gnu.org
2011-01-26 18:21 ` [Bug rtl-optimization/47270] [4.4/4.5/4.6 Regression] GCC produces unnecessary " d.g.gorbachev at gmail dot com
2011-04-16 10:30 ` [Bug rtl-optimization/47270] [4.4/4.5/4.6/4.7 " jakub at gcc dot gnu.org
2012-03-13 14:54 ` [Bug rtl-optimization/47270] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-07-02 13:13 ` [Bug rtl-optimization/47270] [4.6/4.7/4.8 " rguenth at gcc dot gnu.org
2013-03-05 23:29 ` steven at gcc dot gnu.org
2013-04-12 15:18 ` [Bug rtl-optimization/47270] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-04-12 20:34 ` d.g.gorbachev at gmail dot com
2013-12-25  0:00 ` steven at gcc dot gnu.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).