https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60145
--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> --- Created attachment 40173 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40173&action=edit 2 patterns for the 4-byte case The 2-byte case should be improved by r242909 but the 4-byte case just leads to insane patterns if tried to catch such code in the backend. FYI I attached 2 patterns that would improve your code, but I didn't even consider to propose them for revirew... If your intention is to swap bytes to adjust endianess, you might consider __builtin_bswap32, cf. https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-g_t_005f_005fbuiltin_005fbswap32-4387 If you want to compose 32-bit values out of 8-bit values, you can use a union as indicated in your example, or you can use vectors which is a GCC extension: #include <stdint.h> typedef uint8_t v4 __attribute__((vector_size (4))); uint32_t join4 (uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) { return (uint32_t) (v4) { b0, b1, b2, b3 }; } uint32_t join4 (uint8_t b0, uint8_t b1, uint8_t b2, uint8_t b3) { v4 vec; vec[0] = b0; vec[1] = b1; vec[2] = b2; vec[3] = b3; return (uint32_t) vec; } And as always, consider inlining such functions.