Why does optimisation kill this function?

In C++, pointer arguments are assumed not to alias (except char*) if they point to fundamentally different types (“strict aliasing” rules). This allows some optimizations.

Here, u64 tmp is never modified as u64.
A content of u32* is modified but may be unrelated to ‘u64 tmp‘ so may be seen as nop for u64 tmp.

Leave a Comment