public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/40900]  New: redundant sign extend of short function returned value
@ 2009-07-29  8:56 carrot at google dot com
  2009-07-29  8:57 ` [Bug target/40900] " carrot at google dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: carrot at google dot com @ 2009-07-29  8:56 UTC (permalink / raw)
  To: gcc-bugs

Compile the following code with options -Os -mthumb -march=armv5te

extern short shortv2();
short shortv1()
{
  return shortv2();
}

Gcc generates

        push    {r3, lr}
        bl      shortv2
        lsl     r0, r0, #16    // A
        asr     r0, r0, #16    // B
        pop     {r3, pc}

The returned value in register r0 is already a sign extended short value, but
instructions A and B sign extend it again. So these two instructions are
redundant.


-- 
           Summary: redundant sign extend of short function returned value
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carrot at google dot com
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: arm-eabi


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


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

* [Bug target/40900] redundant sign extend of short function returned value
  2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
@ 2009-07-29  8:57 ` carrot at google dot com
  2009-07-29  9:34 ` ramana at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: carrot at google dot com @ 2009-07-29  8:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from carrot at google dot com  2009-07-29 08:57 -------
Created an attachment (id=18266)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18266&action=view)
test case


-- 


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


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

* [Bug target/40900] redundant sign extend of short function returned value
  2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
  2009-07-29  8:57 ` [Bug target/40900] " carrot at google dot com
@ 2009-07-29  9:34 ` ramana at gcc dot gnu dot org
  2009-07-29 10:33 ` [Bug rtl-optimization/40900] " ramana at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-07-29  9:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ramana at gcc dot gnu dot org  2009-07-29 09:33 -------
You don't see it on ARM for this case because of tail-calling. But for Thumb or
without sibcall optimizations you do see this problem. 


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-07-29 09:33:56
               date|                            |


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


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

* [Bug rtl-optimization/40900] redundant sign extend of short function returned value
  2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
  2009-07-29  8:57 ` [Bug target/40900] " carrot at google dot com
  2009-07-29  9:34 ` ramana at gcc dot gnu dot org
@ 2009-07-29 10:33 ` ramana at gcc dot gnu dot org
  2009-12-12  1:13 ` rearnsha at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-07-29 10:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ramana at gcc dot gnu dot org  2009-07-29 10:33 -------
I don't think this is a backend specific problem but more an rtl-optimization
problem where combine with its sign extension detection machinery should be
extended to detect such cases. 


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |rtl-optimization


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


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

* [Bug rtl-optimization/40900] redundant sign extend of short function returned value
  2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
                   ` (2 preceding siblings ...)
  2009-07-29 10:33 ` [Bug rtl-optimization/40900] " ramana at gcc dot gnu dot org
@ 2009-12-12  1:13 ` rearnsha at gcc dot gnu dot org
  2010-06-18 16:39 ` ebotcazou at gcc dot gnu dot org
  2010-06-18 16:41 ` ebotcazou at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2009-12-12  1:13 UTC (permalink / raw)
  To: gcc-bugs



-- 

rearnsha at gcc dot gnu dot org changed:

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


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


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

* [Bug rtl-optimization/40900] redundant sign extend of short function returned value
  2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
                   ` (3 preceding siblings ...)
  2009-12-12  1:13 ` rearnsha at gcc dot gnu dot org
@ 2010-06-18 16:39 ` ebotcazou at gcc dot gnu dot org
  2010-06-18 16:41 ` ebotcazou at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-06-18 16:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from ebotcazou at gcc dot gnu dot org  2010-06-18 16:39 -------
Subject: Bug 40900

Author: ebotcazou
Date: Fri Jun 18 16:38:29 2010
New Revision: 161006

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161006
Log:
        PR rtl-optimization/40900
        * expr.c (expand_expr_real_1) <SSA_NAME>: Fix long line.  Save the
        original expression for later reuse.
        <expand_decl_rtl>: Use promote_function_mode to compute the signedness
        of the promoted RTL for a SSA_NAME on the LHS of a call statement.

Added:
    trunk/gcc/testsuite/gcc.target/arm/pr40900.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/40900] redundant sign extend of short function returned value
  2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
                   ` (4 preceding siblings ...)
  2010-06-18 16:39 ` ebotcazou at gcc dot gnu dot org
@ 2010-06-18 16:41 ` ebotcazou at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-06-18 16:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ebotcazou at gcc dot gnu dot org  2010-06-18 16:40 -------
On the mainline.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.0


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


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

end of thread, other threads:[~2010-06-18 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-29  8:56 [Bug target/40900] New: redundant sign extend of short function returned value carrot at google dot com
2009-07-29  8:57 ` [Bug target/40900] " carrot at google dot com
2009-07-29  9:34 ` ramana at gcc dot gnu dot org
2009-07-29 10:33 ` [Bug rtl-optimization/40900] " ramana at gcc dot gnu dot org
2009-12-12  1:13 ` rearnsha at gcc dot gnu dot org
2010-06-18 16:39 ` ebotcazou at gcc dot gnu dot org
2010-06-18 16:41 ` ebotcazou 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).