public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/45804] New: ARM: unnecessary sign extension
@ 2010-09-27 10:49 felipe.contreras at gmail dot com
  2010-09-27 16:20 ` [Bug target/45804] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: felipe.contreras at gmail dot com @ 2010-09-27 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ARM: unnecessary sign extension
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: felipe.contreras@gmail.com


In the following code gcc add an unnecessary uxth operation.

static inline uint16_t read16_be(const uint8_t *p)
{
    uint16_t v;
    __asm__("ldrh %0, %1" : "=r"(v) : "m"(*(const uint16_t *)p));
    __asm__("rev16 %0, %0" : "+r"(v));
    return v;
}

Many other people have experienced this issue:
http://article.gmane.org/gmane.comp.video.ffmpeg.cvs/33470
http://article.gmane.org/gmane.comp.video.ffmpeg.devel/106781
https://bugs.launchpad.net/gcc-linaro/+bug/634682


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

* [Bug target/45804] ARM: unnecessary sign extension
  2010-09-27 10:49 [Bug c/45804] New: ARM: unnecessary sign extension felipe.contreras at gmail dot com
@ 2010-09-27 16:20 ` rguenth at gcc dot gnu.org
  2010-09-27 18:40 ` rearnsha at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-09-27 16:20 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Target|                            |arm-*-*
          Component|c                           |target
           Severity|normal                      |enhancement


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

* [Bug target/45804] ARM: unnecessary sign extension
  2010-09-27 10:49 [Bug c/45804] New: ARM: unnecessary sign extension felipe.contreras at gmail dot com
  2010-09-27 16:20 ` [Bug target/45804] " rguenth at gcc dot gnu.org
@ 2010-09-27 18:40 ` rearnsha at gcc dot gnu.org
  2010-09-27 23:40 ` felipe.contreras at gmail dot com
  2010-09-28 12:06 ` rearnsha at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2010-09-27 18:40 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |rearnsha at gcc dot gnu.org
         Resolution|                            |INVALID

--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2010-09-27 16:30:35 UTC ---
This particular case is invalid.  

The ARM ABI requires that short and char result types are extended to 32 bits
(using signed or unsigned extension as appropriate) before being returned. 
Since the compiler can't see inside the asm block to work out what is being
done it cannot remove the uxth instruction on the result.

This does not mean that some of your x-refed reports are invalid though.


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

* [Bug target/45804] ARM: unnecessary sign extension
  2010-09-27 10:49 [Bug c/45804] New: ARM: unnecessary sign extension felipe.contreras at gmail dot com
  2010-09-27 16:20 ` [Bug target/45804] " rguenth at gcc dot gnu.org
  2010-09-27 18:40 ` rearnsha at gcc dot gnu.org
@ 2010-09-27 23:40 ` felipe.contreras at gmail dot com
  2010-09-28 12:06 ` rearnsha at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: felipe.contreras at gmail dot com @ 2010-09-27 23:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Felipe Contreras <felipe.contreras at gmail dot com> 2010-09-27 19:02:19 UTC ---
(In reply to comment #1)
> This particular case is invalid.  
> 
> The ARM ABI requires that short and char result types are extended to 32 bits
> (using signed or unsigned extension as appropriate) before being returned. 
> Since the compiler can't see inside the asm block to work out what is being
> done it cannot remove the uxth instruction on the result.

What do you mean by "returned"? This is an inline function, so it depends
entirely on what the referencing code is doing whether or not this value is
returned, as function return.

Say:

if ((read16_be(data) & 0xfffe) == 0xfff8)

> This does not mean that some of your x-refed reports are invalid though.

Come again?


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

* [Bug target/45804] ARM: unnecessary sign extension
  2010-09-27 10:49 [Bug c/45804] New: ARM: unnecessary sign extension felipe.contreras at gmail dot com
                   ` (2 preceding siblings ...)
  2010-09-27 23:40 ` felipe.contreras at gmail dot com
@ 2010-09-28 12:06 ` rearnsha at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2010-09-28 12:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2010-09-27 21:52:38 UTC ---
(In reply to comment #2)
> 
> What do you mean by "returned"? This is an inline function, so it depends
> entirely on what the referencing code is doing whether or not this value is
> returned, as function return.

You didn't cite any context of the use.  Just a single function.


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

end of thread, other threads:[~2010-09-27 21:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-27 10:49 [Bug c/45804] New: ARM: unnecessary sign extension felipe.contreras at gmail dot com
2010-09-27 16:20 ` [Bug target/45804] " rguenth at gcc dot gnu.org
2010-09-27 18:40 ` rearnsha at gcc dot gnu.org
2010-09-27 23:40 ` felipe.contreras at gmail dot com
2010-09-28 12:06 ` rearnsha at gcc dot gnu.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).