Patchwork catch builtin_bswap16 construct

login
register
mail settings
Submitter Oleg Endo
Date Sept. 26, 2012, 8:52 p.m.
Message ID <1348692772.9306.1.camel@yam-132-YW-E178-FTW>
Download mbox | patch
Permalink /patch/187204/
State New
Headers show

Comments

Oleg Endo - Sept. 26, 2012, 8:52 p.m.
On Mon, 2012-09-24 at 09:47 +0200, Oleg Endo wrote:
> On Mon, 2012-09-24 at 09:15 +0200, Eric Botcazou wrote:
> > > A while ago I've tried doing that for SH (implementing bswap16 with RTL
> > > combine).  It was like an explosion of patterns, because combine would
> > > try out a lot of things depending on the surrounding code around the
> > > actual bswap16.  In the end I decided to drop that stuff for the most
> > > part.
> > 
> > OK, thanks for your feedback.  Note that you won't get the benefit of the 
> > optimization for SH if you don't define a bswaphi2 pattern.
> 
> Sure sure.  I'll resume my efforts after Christophe's patch is in.
> 
> > 
> > > BTW, the built-in documentation says:
> > > 
> > > Built-in Function: int16_t __builtin_bswap16 (int16_t x)
> > > Built-in Function: int32_t __builtin_bswap32 (int32_t x)
> > > 
> > > However, it seems the result is always unsigned for those.
> > 
> > Yes, builtins.def contains:
> > 
> > DEF_GCC_BUILTIN        (BUILT_IN_BSWAP16, "bswap16", BT_FN_UINT16_UINT16, 
> > ATTR_CONST_NOTHROW_LEAF_LIST)
> > DEF_GCC_BUILTIN        (BUILT_IN_BSWAP32, "bswap32", BT_FN_UINT32_UINT32, 
> > ATTR_CONST_NOTHROW_LEAF_LIST)
> > DEF_GCC_BUILTIN        (BUILT_IN_BSWAP64, "bswap64", BT_FN_UINT64_UINT64, 
> > ATTR_CONST_NOTHROW_LEAF_LIST)
> > 
> > The documentation indeed needs to be fixed.
> > 
> 
> OK, I'll check it out.

I have committed the attached obvious patch as rev 191774.

Cheers,
Oleg


ChangeLog:

	* doc/extend.texi (bswap Builtins): Change signed types to
	unsigned types.

Patch

Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi	(revision 191773)
+++ gcc/doc/extend.texi	(working copy)
@@ -8611,18 +8611,18 @@ 
 are @code{long double}.
 @end deftypefn
 
-@deftypefn {Built-in Function} int16_t __builtin_bswap16 (int16_t x)
+@deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
 Returns @var{x} with the order of the bytes reversed; for example,
 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
 exactly 8 bits.
 @end deftypefn
 
-@deftypefn {Built-in Function} int32_t __builtin_bswap32 (int32_t x)
+@deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
 Similar to @code{__builtin_bswap16}, except the argument and return types
 are 32-bit.
 @end deftypefn
 
-@deftypefn {Built-in Function} int64_t __builtin_bswap64 (int64_t x)
+@deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
 Similar to @code{__builtin_bswap32}, except the argument and return types
 are 64-bit.
 @end deftypefn