... is in the eye of the beholder. They exploit every corner of undefined behavior to the benefit of performance. Indeed other compilers might be "safer."
Keep in mind that they also provide you with UBSan to help you detect when you're doing it wrong.
Isn't the "they" in this thread gcc, or did I misread something?
Note that UBSan is (mostly? totally? originally?) a Google project and it's been ported to both clang and gcc.
The compiler writers write the compiler with the expectation that the program being compiled is correct i.e. to the specification.
Now when the program fails to be correct, optimizations can result in "weird" results, which is not really incorrect since the input was incorrect.
If you're able to narrow it down that far why not then fix your bug?
Essentially, it was not worth more of my time to figure out how aggressive optimizations were breaking the parts of a memory bandwidth constrained function that aren't worth optimizing in the first place.
For GCC inline assembly means "take your grubby hands off". For clang it's essentially an invitation to do whatever.
That's not true at all. Clang respects the clobbers entry on inline assembly and does not do whatever it wants. See GCC's documentation on it: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobber...
Based off of your description you probably just needed to add the "memory" clobber to tell the compiler that any registers it might have kept are no longer valid.