public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/40210]  New: gcc needs byte swap builtins
@ 2009-05-20 18:48 eric-bugs at omnifarious dot org
  2009-05-20 19:39 ` [Bug tree-optimization/40210] gcc byte swap builtins inadequately optimized eric-bugs at omnifarious dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: eric-bugs at omnifarious dot org @ 2009-05-20 18:48 UTC (permalink / raw)
  To: gcc-bugs

gcc needs some built in functions for byte swapping.

I've been experimenting with the various versions of byte swapping functions
out there, and they either result in code that's opaque to the optimizer (i.e.
swapping something twice is not considered a null operation) or the optimizer
doesn't recognize that a byte swap is what's happening and renders it as a
complex series of shift, and and or instructions.

I know very little about the internals of gcc, but my ignorant preference would
be to make tree-ssa recognize that code like this:

inline uint64_t byteswap_64(const uint64_t x)
{
   return
      ((((x) & 0xff00000000000000ull) >> 56)
      | (((x) & 0x00ff000000000000ull) >> 40)
      | (((x) & 0x0000ff0000000000ull) >> 24)
      | (((x) & 0x000000ff00000000ull) >> 8)
      | (((x) & 0x00000000ff000000ull) << 8)
      | (((x) & 0x0000000000ff0000ull) << 24)
      | (((x) & 0x000000000000ff00ull) << 40)
      | (((x) & 0x00000000000000ffull) << 56));
}

is a byte swap and optimize appropriately.  If this were being done to an
entire array, it might even be possible to vectorize it efficiently.

This would also mean that code to pull specific bits out of a pre or post swap
value could be moved around and fiddled to get the value out of a different
place if it made for more efficient register usage.


-- 
           Summary: gcc needs byte swap builtins
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eric-bugs at omnifarious dot org


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


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

end of thread, other threads:[~2021-07-10  8:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40210-4@http.gcc.gnu.org/bugzilla/>
2011-10-07 18:23 ` [Bug tree-optimization/40210] gcc byte swap builtins inadequately optimized pluto at agmk dot net
2011-10-07 18:29 ` pinskia at gcc dot gnu.org
2011-10-07 18:46 ` pluto at agmk dot net
2021-07-08 10:48 ` cvs-commit at gcc dot gnu.org
2021-07-10  8:34 ` roger at nextmovesoftware dot com
2009-05-20 18:48 [Bug tree-optimization/40210] New: gcc needs byte swap builtins eric-bugs at omnifarious dot org
2009-05-20 19:39 ` [Bug tree-optimization/40210] gcc byte swap builtins inadequately optimized eric-bugs at omnifarious dot org
2009-05-20 20:05 ` jakub at gcc dot gnu dot org
2009-05-20 20:22 ` eric-bugs at omnifarious dot org
2009-06-10 17:37 ` hp 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).