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



Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

             Status|NEW                         |ASSIGNED

         AssignedTo|unassigned at gcc dot       |ebotcazou at gcc dot

                   |gnu.org                     |gnu.org



--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-11-02 
17:45:54 UTC ---

> The first example isn't *that* dumb, as a cut-down test case of real code 

> which may look more complex in reality.



OK, and I can indeed think of some usage patterns in real life.



> If the real code really *is* as simple as my test case, you're right that

> perhaps we *could* optimise it ourselves by eschewing the normal accessor

> macros for explicit-endian values, and manually byteswapping the constant

> instead.

> 

> But really, we shouldn't *have* to. The compiler can see what's happening, and

> it can deal with it a whole lot better than we can, especially when it comes

> to loads and stores. 



Another category would be comparisons then:



int compare1 (int x)

{

  return __builtin_bswap32 (x) == 0xdeadbeef;

}



int compare2 (int x, int y)

{

  return __builtin_bswap32 (x) == __builtin_bswap32 (y);

}



Will have a look shortly.

Reply via email to