https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97784
--- Comment #2 from Segher Boessenkool ---
No, it is exactly the same with unsigned types :-(
Use -Dlong="unsigned long" or use #define O ^ (as in my original test).
I forgot about this signed thing, but it has nothing to do with it (that
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97784
--- Comment #1 from Andrew Pinski ---
Reassociation is done for signed types and places where it could introduce
overflows.
If you -fwrapv, you should get the optimization. Likewise for unsigned types.