public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/11708] New: Non-Optimal jump code generation.
@ 2003-07-29 13:42 naveens at noida dot hcltech dot com
  2003-07-29 13:46 ` [Bug optimization/11708] " naveens at noida dot hcltech dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: naveens at noida dot hcltech dot com @ 2003-07-29 13:42 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Non-Optimal jump code generation.
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: naveens at noida dot hcltech dot com
                CC: gcc-bugs at gcc dot gnu dot org,joern dot rennecke at
                    superh dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sh-unknown-elf

I am seeing some redundant jumps in code generated by GCC3.3 and 
the mainline. e.g. I see this assembly generated for 
one of my benchmark (sh-elf target, options: -ml -m4 -O2)

        ! basic block 1
        cmp/pl  r3
        mov.w   .L147,r1
        bt      .L3     <--- conditional branch C1
        mov     #0,r1
        bra     .L208   <--- Branch B1
        mov     r1,r3   <--- delay slot
.L3:
        ! basic block 2
        mov     r1,r3
.L208:
        mov.w   .L149,r2
        mov.w   .L150,r1
        cmp/gt  r1,r3
        bt      .L7

It seems it should be better generated as:

        ! basic block 1
        cmp/pl  r3
        mov.w   .L147,r1
        bt      .L208    <--- conditional branch C1
        mov     #0,r1
.L208:
       ! basic block 2
        mov     r1,r3
        mov.w   .L149,r2
        mov.w   .L150,r1
        cmp/gt  r1,r3
        bt      .L7

So, a jump(bra) instruction could be eliminated.


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

* [Bug optimization/11708] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
@ 2003-07-29 13:46 ` naveens at noida dot hcltech dot com
  2003-07-29 13:48 ` pinskia at physics dot uc dot edu
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: naveens at noida dot hcltech dot com @ 2003-07-29 13:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From naveens at noida dot hcltech dot com  2003-07-29 13:46 -------
Created an attachment (id=4505)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4505&action=view)
Preprocessed file to reproduce the bug.

compile with 
sh-elf-gcc -ml -m4 -S -O2 -dA BUG.c to get the assembler dump.


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

* [Bug optimization/11708] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
  2003-07-29 13:46 ` [Bug optimization/11708] " naveens at noida dot hcltech dot com
@ 2003-07-29 13:48 ` pinskia at physics dot uc dot edu
  2003-07-29 14:10 ` naveens at noida dot hcltech dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-29 13:48 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pessimizes-code


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

* [Bug optimization/11708] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
  2003-07-29 13:46 ` [Bug optimization/11708] " naveens at noida dot hcltech dot com
  2003-07-29 13:48 ` pinskia at physics dot uc dot edu
@ 2003-07-29 14:10 ` naveens at noida dot hcltech dot com
  2003-07-29 14:20 ` [Bug optimization/11708] [sh4-elf-gcc] " naveens at noida dot hcltech dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: naveens at noida dot hcltech dot com @ 2003-07-29 14:10 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From naveens at noida dot hcltech dot com  2003-07-29 14:10 -------
It seems, delay slot scheduling has the responsibility of generating 
optimal code here. 

In fact, it is able to do the required transformation in some cases. e.g.

Consider this part of the assembler 
with -fno-delayed-branch -O2 -ml -m4 -S -dA

        ! basic block 25
        cmp/pl  r3
        mov.w   .L147,r1
        bt      .L203
        bra     .L93
        nop
.L203:
.L36:
        ! basic block 26

   ..... snipped ...

.L93:
        ! basic block 69
        mov     #0,r1
        bra     .L36
        nop
        .align 5

With -fdelayed-branch, this is optimized to:

         ! basic block 25
        cmp/pl  r3
        mov.w   .L147,r1
        bt      .L36
        mov     #0,r1
.L36:
        ! basic block 26
        mov.w   .L136,r3
        mov.w   .L149,r2
        add     r1,r3
        mov.w   .L150,r1
        cmp/gt  r1,r3

So, it seems that delayed branch scheduling is able to 
optimize some cases, but misses some. I will try to 
confirm the reason.


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (2 preceding siblings ...)
  2003-07-29 14:10 ` naveens at noida dot hcltech dot com
@ 2003-07-29 14:20 ` naveens at noida dot hcltech dot com
  2003-08-11 12:42 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: naveens at noida dot hcltech dot com @ 2003-07-29 14:20 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


naveens at noida dot hcltech dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Non-Optimal jump code       |[sh4-elf-gcc] Non-Optimal
                   |generation.                 |jump code generation.


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (3 preceding siblings ...)
  2003-07-29 14:20 ` [Bug optimization/11708] [sh4-elf-gcc] " naveens at noida dot hcltech dot com
@ 2003-08-11 12:42 ` pinskia at gcc dot gnu dot org
  2003-08-11 17:48 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-11 12:42 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (4 preceding siblings ...)
  2003-08-11 12:42 ` pinskia at gcc dot gnu dot org
@ 2003-08-11 17:48 ` pinskia at gcc dot gnu dot org
  2003-08-25  0:04 ` dhazeghi at yahoo dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-11 17:48 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (5 preceding siblings ...)
  2003-08-11 17:48 ` pinskia at gcc dot gnu dot org
@ 2003-08-25  0:04 ` dhazeghi at yahoo dot com
  2003-09-17  7:20 ` naveens at noida dot hcltech dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-25  0:04 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-25 00:04:00
               date|                            |


------- Additional Comments From dhazeghi at yahoo dot com  2003-08-25 00:03 -------
Confirmed with mainline (20030824).


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (6 preceding siblings ...)
  2003-08-25  0:04 ` dhazeghi at yahoo dot com
@ 2003-09-17  7:20 ` naveens at noida dot hcltech dot com
  2004-01-03 19:46 ` pinskia at gcc dot gnu dot org
  2004-01-05  6:01 ` naveens at noida dot hcltech dot com
  9 siblings, 0 replies; 11+ messages in thread
From: naveens at noida dot hcltech dot com @ 2003-09-17  7:20 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From naveens at noida dot hcltech dot com  2003-09-17 07:02 -------
Something weird has happened on the mainline. 
I don't get any assembler ouput (-O2 -m4 -ml) for this test case, 
when I compile with snapshot of 12th Sep, 2003. 

Anybody else seeing this sort of a problem or there is something 
wrong in my environment ?


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (7 preceding siblings ...)
  2003-09-17  7:20 ` naveens at noida dot hcltech dot com
@ 2004-01-03 19:46 ` pinskia at gcc dot gnu dot org
  2004-01-05  6:01 ` naveens at noida dot hcltech dot com
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-03 19:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-03 19:45 -------
no -O2 enables -funit-at-a-time which removes static functions, remove the static from the 
file and it should produce code.

-- 


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


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

* [Bug optimization/11708] [sh4-elf-gcc] Non-Optimal jump code generation.
  2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
                   ` (8 preceding siblings ...)
  2004-01-03 19:46 ` pinskia at gcc dot gnu dot org
@ 2004-01-05  6:01 ` naveens at noida dot hcltech dot com
  9 siblings, 0 replies; 11+ messages in thread
From: naveens at noida dot hcltech dot com @ 2004-01-05  6:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From naveens at noida dot hcltech dot com  2004-01-05 06:01 -------
Yes, thats right !! although it wasn't obvious immediately.

-- 


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


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

end of thread, other threads:[~2004-01-05  6:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29 13:42 [Bug optimization/11708] New: Non-Optimal jump code generation naveens at noida dot hcltech dot com
2003-07-29 13:46 ` [Bug optimization/11708] " naveens at noida dot hcltech dot com
2003-07-29 13:48 ` pinskia at physics dot uc dot edu
2003-07-29 14:10 ` naveens at noida dot hcltech dot com
2003-07-29 14:20 ` [Bug optimization/11708] [sh4-elf-gcc] " naveens at noida dot hcltech dot com
2003-08-11 12:42 ` pinskia at gcc dot gnu dot org
2003-08-11 17:48 ` pinskia at gcc dot gnu dot org
2003-08-25  0:04 ` dhazeghi at yahoo dot com
2003-09-17  7:20 ` naveens at noida dot hcltech dot com
2004-01-03 19:46 ` pinskia at gcc dot gnu dot org
2004-01-05  6:01 ` naveens at noida dot hcltech 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).