This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/40210] gcc byte swap builtins inadequately optimized



------- Comment #6 from jakub at gcc dot gnu dot org  2009-05-20 20:05 -------
There are plenty other possible builtin bswap optimizations.  E.g.
extern void bar (void);

void foo (int x)
{
  if (__builtin_bswap32 (x) == __builtin_bswap32 (0x1234567))
    bar ();
}

should be optimized into if (x == 0x1234567) (only for EQ_EXPR/NE_EXPR),
similarly __builtin_bswap32 (x) == 0x1234567 should be optimized into
x == __builtin_bswap32 (0x1234567) because the latter can be swapped at compile
time, similarly __builtin_bswap32 (__builtin_bswap32 (x) | 0x1234) could
be optimized into x | __builtin_bswap32 (0x1234) (similarly for ^ or & or ~),
etc.  The question is if enough projects start using these builtins to make it
worth spending compile time on it and what exact optimizations are useful on
real-world code.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]