Forum Discussion
Altera_Forum
Honored Contributor
14 years agogcc generates incorrect code
Hi, It appears that there is a bug in this version of the nios2 compiler at higher optimisation levels. $ nios2-elf-gcc --version nios2-elf-gcc (Altera 11.1sp2 Build 259) 4.1.2 Copyri...
Altera_Forum
Honored Contributor
14 years agoYou'll also find that the x86 cpu ignores all the high bits of a shift count.
Oh definitions like:static const uint32_t one = 1u;are just completely pointless. It is much clearer if you just write: uint32_t makeMask(uint32_t count)
{
return count >= 31 ? 0xffffffffu : (1u << count) - 1;
} All the temporary variables just make it harder to read. (That isn't quite your function, but is closer to the one you wanted!)