public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/18233] New: extraneous inc/dec pair
@ 2004-10-30 19:15 nathan at gcc dot gnu dot org
  2004-10-30 19:16 ` [Bug tree-optimization/18233] " nathan at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-10-30 19:15 UTC (permalink / raw)
  To: gcc-bugs

The attached code produces the following assembler
foo:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        testl   %eax, %eax
        jne     .L7
        leave
        ret
        .p2align 2,,3
.L7:
        xorl    %edx, %edx
        bsfl    %eax, %eax
        sete    %dl
        negl    %edx
        orl     %edx, %eax
        incl    %eax
        decl    %eax
        leave
        ret

There are two issues
1) the incl/decl pair fails to be eliminated.  I presume this is because the
define_insn_and_split that i86 uses gets split too late for CSE to fold in the
subsequent decrement of the source code.  Perhaps it could be partially split
earlier, leaving the conditional move stuff to later.  I've not examined it in
greate detal.

2) Possibly much harder.  The ffs expansion has no knowledge that its input is
nonzero, and therefore need not deal with that case.  I gues this will be
systemic to other targets.  I wonder what can be done about that -- possibly
duplicate FFS_NON_ZERO_EXPR and FFS_MAYBE_ZERO_EXPR nodes?

-- 
           Summary: extraneous inc/dec pair
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nathan at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug tree-optimization/18233] extraneous inc/dec pair
  2004-10-30 19:15 [Bug tree-optimization/18233] New: extraneous inc/dec pair nathan at gcc dot gnu dot org
@ 2004-10-30 19:16 ` nathan at gcc dot gnu dot org
  2004-10-30 19:28 ` [Bug rtl-optimization/18233] " pinskia at gcc dot gnu dot org
  2004-11-11 20:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-10-30 19:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-10-30 19:16 -------
Created an attachment (id=7436)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7436&action=view)
test case


-- 


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


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

* [Bug rtl-optimization/18233] extraneous inc/dec pair
  2004-10-30 19:15 [Bug tree-optimization/18233] New: extraneous inc/dec pair nathan at gcc dot gnu dot org
  2004-10-30 19:16 ` [Bug tree-optimization/18233] " nathan at gcc dot gnu dot org
@ 2004-10-30 19:28 ` pinskia at gcc dot gnu dot org
  2004-11-11 20:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-30 19:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-30 19:28 -------
On PPC, we get:
        cmpwi cr0,r3,0
        li r2,0
        neg r0,r3
        and r0,r3,r0
        bne- cr0,L7
        mr r3,r2
        blr
L7:
        cntlzw r0,r0
        subfic r2,r0,31
        mr r3,r2
        blr
which is good and there is no extra subfic and also ffs has definition to return 0 for 0 so the extran 
subtraction on the ffs causes this to be good code on PPC.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
          Component|tree-optimization           |rtl-optimization
           Keywords|                            |missed-optimization


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


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

* [Bug rtl-optimization/18233] extraneous inc/dec pair
  2004-10-30 19:15 [Bug tree-optimization/18233] New: extraneous inc/dec pair nathan at gcc dot gnu dot org
  2004-10-30 19:16 ` [Bug tree-optimization/18233] " nathan at gcc dot gnu dot org
  2004-10-30 19:28 ` [Bug rtl-optimization/18233] " pinskia at gcc dot gnu dot org
@ 2004-11-11 20:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-11 20:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-11 20:15 -------
Confirmed.  We are splitting ffs late which causes this problem (maybe doing an expand instead of 
splitter fixes the problem).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-11 20:15:49
               date|                            |


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


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

end of thread, other threads:[~2004-11-11 20:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-30 19:15 [Bug tree-optimization/18233] New: extraneous inc/dec pair nathan at gcc dot gnu dot org
2004-10-30 19:16 ` [Bug tree-optimization/18233] " nathan at gcc dot gnu dot org
2004-10-30 19:28 ` [Bug rtl-optimization/18233] " pinskia at gcc dot gnu dot org
2004-11-11 20:16 ` 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).