public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/35926] Pushing / Poping ebx without using it.
       [not found] <bug-35926-4@http.gcc.gnu.org/bugzilla/>
@ 2011-01-25 19:51 ` tony.poppleton at gmail dot com
  2011-01-27 17:11 ` tony.poppleton at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: tony.poppleton at gmail dot com @ 2011-01-25 19:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tony Poppleton <tony.poppleton at gmail dot com> 2011-01-25 19:33:20 UTC ---
I can confirm this still exists on both GCC 4.5.1 and GCC 4.6.0 (20110115),
when compiling with -O3.

I did some basic investigation into the files produced by the --dump-tree-all
flag, which shows:

add (struct toto_s * a, struct toto_s * b)
{
  int64_t tmp;
  int D.2686;
  struct toto_s * D.2685;
  long long int D.2684;
  int D.2683;
  int b.1;
  long long int D.2681;
  int a.0;

<bb 2>:
  a.0_2 = (int) a_1(d);
  D.2681_3 = (long long int) a.0_2;
  b.1_5 = (int) b_4(d);
  D.2683_6 = b.1_5 & -2;
  D.2684_7 = (long long int) D.2683_6;
  tmp_8 = D.2681_3 + D.2684_7;
  D.2686_9 = (int) tmp_8;
  D.2685_10 = (struct toto_s *) D.2686_9;
  return D.2685_10;
}

What I don't understand here, is the excessive casting;

The addition in tmp_8 is being done as (long long int), yet both terms are
ultimiately derived from (int) variables.  Is this casting to (long long int)
necessary to deal with an overflow on the addition?

If so, then why does the final asm code not appear to be catering for overflow?

Alternatively, could the whole block be simplified down to (int) during this
phase of the compile, thereby fixing the subsequent unnecessary usage of BX
during the RTL phase (as per comment #3)?

As an aside (possibly another bug report?), it appears there is a regression in
4.6.0, which requires the use of an additional movl compared to what is in the
original bug description (4.5.1 does not suffer from this)

         .file   "PR35926.c"
        .text
        .p2align 4,,15
        .globl  add
        .type   add, @function
add:
.LFB0:
        .cfi_startproc
        pushl   %ebx
        .cfi_def_cfa_offset 8
        .cfi_offset 3, -8
        movl    12(%esp), %eax
        movl    8(%esp), %ecx
        popl    %ebx
        .cfi_def_cfa_offset 4
        .cfi_restore 3
        andl    $-2, %eax
        addl    %eax, %ecx       <==== order of regs inverted
        movl    %ecx, %eax       <==== resulting in unnecessary movl
        ret
        .cfi_endproc
.LFE0:
        .size   add, .-add
        .ident  "GCC: (GNU) 4.6.0 20110115 (experimental)"
        .section        .note.GNU-stack,"",@progbits


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

* [Bug target/35926] Pushing / Poping ebx without using it.
       [not found] <bug-35926-4@http.gcc.gnu.org/bugzilla/>
  2011-01-25 19:51 ` [Bug target/35926] Pushing / Poping ebx without using it tony.poppleton at gmail dot com
@ 2011-01-27 17:11 ` tony.poppleton at gmail dot com
  2011-02-01 13:44 ` tony.poppleton at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: tony.poppleton at gmail dot com @ 2011-01-27 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Tony Poppleton <tony.poppleton at gmail dot com> 2011-01-27 16:55:26 UTC ---
For the record, the additional movl noticed above in GCC 4.6.0 has been
factored out into PR47477


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

* [Bug target/35926] Pushing / Poping ebx without using it.
       [not found] <bug-35926-4@http.gcc.gnu.org/bugzilla/>
  2011-01-25 19:51 ` [Bug target/35926] Pushing / Poping ebx without using it tony.poppleton at gmail dot com
  2011-01-27 17:11 ` tony.poppleton at gmail dot com
@ 2011-02-01 13:44 ` tony.poppleton at gmail dot com
  2013-04-10  1:42 ` tony.poppleton at gmail dot com
  2021-12-25  7:07 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 8+ messages in thread
From: tony.poppleton at gmail dot com @ 2011-02-01 13:44 UTC (permalink / raw)
  To: gcc-bugs

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

Tony Poppleton <tony.poppleton at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2008-12-28 06:57:47         |2011-02-01 13:13
      Known to fail|                            |4.1.2, 4.3.5, 4.4.5, 4.5.2,
                   |                            |4.6.0
           Severity|normal                      |enhancement

--- Comment #7 from Tony Poppleton <tony.poppleton at gmail dot com> 2011-02-01 13:44:28 UTC ---
Set known to fail field, last reconfirmed field, and modified to "enhancement"


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

* [Bug target/35926] Pushing / Poping ebx without using it.
       [not found] <bug-35926-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-02-01 13:44 ` tony.poppleton at gmail dot com
@ 2013-04-10  1:42 ` tony.poppleton at gmail dot com
  2021-12-25  7:07 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 8+ messages in thread
From: tony.poppleton at gmail dot com @ 2013-04-10  1:42 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from Tony Poppleton <tony.poppleton at gmail dot com> 2013-04-10 01:42:20 UTC ---
This appears to be fixed in GCC 4.8.0, compiling with just -S and -O3, the asm
output is now a much simpler:

        .file   "test.c"
        .text
        .p2align 4,,15
        .globl  add
        .type   add, @function
add:
.LFB0:
        .cfi_startproc
        andq    $-2, %rsi
        leaq    (%rdi,%rsi), %rax
        ret
        .cfi_endproc
.LFE0:
        .size   add, .-add
        .ident  "GCC: (GNU) 4.8.0 20130316 (Red Hat 4.8.0-0.17)"
        .section        .note.GNU-stack,"",@progbits


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

* [Bug target/35926] Pushing / Poping ebx without using it.
       [not found] <bug-35926-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-04-10  1:42 ` tony.poppleton at gmail dot com
@ 2021-12-25  7:07 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-25  7:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35926

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.0
             Status|NEW                         |RESOLVED
      Known to work|                            |5.1.0

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 5+.

I know comment #8 said it was fixed in GCC 4.8.0 but I could reproduce the
missed optimization in released GCC 4.8.1 through 4.9.4.

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

* [Bug target/35926] Pushing / Poping ebx without using it.
  2008-04-13 17:49 [Bug c/35926] New: " ppelissi at caramail dot com
  2008-04-14  9:19 ` [Bug target/35926] " rguenth at gcc dot gnu dot org
  2008-04-14 11:13 ` ubizjak at gmail dot com
@ 2008-12-28  7:00 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-12-28  7:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2008-12-28 06:57 -------
Confirmed, still happens even after IRA.  ebx is still being marked as being
used even though the RA does not use it.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|i686-pc-linux-gnu           |
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |i?86-*-*
           Keywords|                            |missed-optimization, ra
   Last reconfirmed|0000-00-00 00:00:00         |2008-12-28 06:57:47
               date|                            |


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


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

* [Bug target/35926] Pushing / Poping ebx without using it.
  2008-04-13 17:49 [Bug c/35926] New: " ppelissi at caramail dot com
  2008-04-14  9:19 ` [Bug target/35926] " rguenth at gcc dot gnu dot org
@ 2008-04-14 11:13 ` ubizjak at gmail dot com
  2008-12-28  7:00 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: ubizjak at gmail dot com @ 2008-04-14 11:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ubizjak at gmail dot com  2008-04-14 11:12 -------
(In reply to comment #2)
> This is setting up the frame pointer which is needed for unwinding/debugging
> on some targets.  You can use -fomit-frame-pointer to avoid this.

No, -fomit-frame-pointer uses %ebp.

%ebx is marked as used due to long long value in %ecx/%ebx. For some reason,
%ebx is still marked as live when function prologue and epilogue are
constructed.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug target/35926] Pushing / Poping ebx without using it.
  2008-04-13 17:49 [Bug c/35926] New: " ppelissi at caramail dot com
@ 2008-04-14  9:19 ` rguenth at gcc dot gnu dot org
  2008-04-14 11:13 ` ubizjak at gmail dot com
  2008-12-28  7:00 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-14  9:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-04-14 09:18 -------
This is setting up the frame pointer which is needed for unwinding/debugging
on some targets.  You can use -fomit-frame-pointer to avoid this.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2021-12-25  7:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-35926-4@http.gcc.gnu.org/bugzilla/>
2011-01-25 19:51 ` [Bug target/35926] Pushing / Poping ebx without using it tony.poppleton at gmail dot com
2011-01-27 17:11 ` tony.poppleton at gmail dot com
2011-02-01 13:44 ` tony.poppleton at gmail dot com
2013-04-10  1:42 ` tony.poppleton at gmail dot com
2021-12-25  7:07 ` pinskia at gcc dot gnu.org
2008-04-13 17:49 [Bug c/35926] New: " ppelissi at caramail dot com
2008-04-14  9:19 ` [Bug target/35926] " rguenth at gcc dot gnu dot org
2008-04-14 11:13 ` ubizjak at gmail dot com
2008-12-28  7:00 ` pinskia at gcc dot gnu 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).