So my current project which I'd been compiling so far with no -O flag, breaks some things on-O2 (although it's spiffy faster). I've been scrounging around a little bit and read up on the evilness of modifying something with a pointer of a different type and how it can break optimizations, particularly in GCC.
Do you think this particular code could break optimizations. Even though I am using a u32* to point to a u64, I'm only using it to read, not modify, and the u32* is not a "mysterious pointer" pointing to an unknown place - it's made directly from &result and dereferenced in the same statement. So it doesn't seem to me to fit the mold of aliasing that breaks optimization - where there's a mysterious pointer floating around that the compiler can have no idea where it points to, and it uses the same type rule to limit the number of options.Code:int rdhi, rdlo, rs, rm; u32 regs; ... u64 result = regs[rm] * (u64) regs[rs]; result += regs[rdlo]; result += (u64) regs[rdhi] << 32; regs[rdhi] = ((u32 *) (&result)); regs[rdlo] = ((u32 *) (&result));