public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/25848]  New: missed-rtl-optimization
@ 2006-01-18 19:58 dtemirbulatov at gmail dot com
  2006-01-18 20:08 ` [Bug rtl-optimization/25848] missed-rtl-optimization pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dtemirbulatov at gmail dot com @ 2006-01-18 19:58 UTC (permalink / raw)
  To: gcc-bugs

This C example:

int f1(int a)
{
  int b = a*2;
  return b+a;
}
---
Currently we produce:
_f1:
        mr 0,3
        slwi 3,3,1
        add 3,3,0
        extsw 3,0
        blr

-----

We should be able to produce:
_f1:
        mr 0,3
        slwi 3,3,1
        add 3,0,3
        blr

,so the "extsw" instruction should go out.


-- 
           Summary: missed-rtl-optimization
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dtemirbulatov at gmail dot com
GCC target triplet: powerpc64-unknown-linux-gnu


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


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

* [Bug rtl-optimization/25848] missed-rtl-optimization
  2006-01-18 19:58 [Bug rtl-optimization/25848] New: missed-rtl-optimization dtemirbulatov at gmail dot com
@ 2006-01-18 20:08 ` pinskia at gcc dot gnu dot org
  2006-08-26  4:19 ` [Bug rtl-optimization/25848] local alloc causing an extra move pinskia at gcc dot gnu dot org
  2006-08-26  4:24 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-18 20:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-01-18 20:08 -------
Hmm, I don't think so as slwi only acts on the lower 32bits so the upper 32bits
have the same sign as before which might be invalid if the b+a overflows.

Actually optimial is:
_f1:
        slwi r0,r3,1
        add r0,r0,r3
        extsw r3,r0
        blr

No extra move.  
The extsw is to extend the return value to 64bits as required by the ABI.
In fact I can think of different cases where this would cause issues.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|3.4.5                       |


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


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

* [Bug rtl-optimization/25848] local alloc causing an extra move
  2006-01-18 19:58 [Bug rtl-optimization/25848] New: missed-rtl-optimization dtemirbulatov at gmail dot com
  2006-01-18 20:08 ` [Bug rtl-optimization/25848] missed-rtl-optimization pinskia at gcc dot gnu dot org
@ 2006-08-26  4:19 ` pinskia at gcc dot gnu dot org
  2006-08-26  4:24 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-26  4:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-08-26 04:19 -------
;; Register 120 in 0.
;; Register 121 in 3.
;; Register 122 in 3.
(insn:HI 6 16 10 2 (set (reg/v:DI 120 [ a ])
        (reg:DI 3 3 [ a ])) 331 {*movdi_internal64} (nil)
    (expr_list:REG_DEAD (reg:DI 3 3 [ a ])
        (expr_list:REG_EQUIV (mem/c/i:DI (plus:DI (reg/f:DI 67 ap)
                    (const_int 48 [0x30])) [2 a+0 S4 A64])
            (nil))))

(insn:HI 10 6 11 2 (set (reg:SI 122)
        (ashift:SI (subreg/s:SI (reg/v:DI 120 [ a ]) 4)
            (const_int 1 [0x1]))) 172 {ashlsi3_no_power} (nil)
    (nil))

(insn:HI 11 10 19 2 (set (reg:SI 121)
        (plus:SI (reg:SI 122)
            (subreg/s:SI (reg/v:DI 120 [ a ]) 4))) 79 {*addsi3_internal1} (nil)
    (expr_list:REG_DEAD (reg:SI 122)
        (expr_list:REG_DEAD (reg/v:DI 120 [ a ])
            (nil))))

(insn:HI 19 11 25 2 (set (reg/i:DI 3 3 [ <result> ])
        (sign_extend:DI (reg:SI 121))) 27 {*rs6000.md:371} (nil)
    (expr_list:REG_DEAD (reg:SI 121)
        (nil)))

(insn:HI 25 19 30 2 (use (reg/i:DI 3 3 [ <result> ])) -1 (nil)
    (nil))


if local alloc put r120 into r3 and 121 in r0, this would have worked.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |missed-optimization, ra
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-26 04:19:35
               date|                            |
            Summary|missed-rtl-optimization     |local alloc causing an extra
                   |                            |move


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


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

* [Bug rtl-optimization/25848] local alloc causing an extra move
  2006-01-18 19:58 [Bug rtl-optimization/25848] New: missed-rtl-optimization dtemirbulatov at gmail dot com
  2006-01-18 20:08 ` [Bug rtl-optimization/25848] missed-rtl-optimization pinskia at gcc dot gnu dot org
  2006-08-26  4:19 ` [Bug rtl-optimization/25848] local alloc causing an extra move pinskia at gcc dot gnu dot org
@ 2006-08-26  4:24 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-26  4:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-08-26 04:23 -------
powerpc-linux-gnu has the same issue with local alloc.
Actually wait this is the same as PR 25381.
extsw is needed for the ABI as slwi zeros the top 32bits.

*** This bug has been marked as a duplicate of 25381 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
 GCC target triplet|powerpc64-unknown-linux-gnu |powerpc*-*-*
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2006-08-26  4:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-18 19:58 [Bug rtl-optimization/25848] New: missed-rtl-optimization dtemirbulatov at gmail dot com
2006-01-18 20:08 ` [Bug rtl-optimization/25848] missed-rtl-optimization pinskia at gcc dot gnu dot org
2006-08-26  4:19 ` [Bug rtl-optimization/25848] local alloc causing an extra move pinskia at gcc dot gnu dot org
2006-08-26  4:24 ` 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).