Quantcast
Channel: C/С++. Why could a simple integer addition on a volatile be translated to a different asm instruction on gcc and clang? - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by Peter Cordes for C/С++. Why could a simple integer addition on a...

This is all because you used volatile and GCC doesn't optimize it as aggressively Without volatile, e.g. for a single ++*int_ptr, you get a memory-destination add. (And hopefully not inc when tuning...

View Article


C/С++. Why could a simple integer addition on a volatile be translated to a...

I wrote a simple loop: int volatile value = 0; void loop(int limit) { for (int i = 0; i < limit; ++i) { ++value; } } I compiled this with gcc and clang(-O3 -fno-unroll-loops) and got different...

View Article

Browsing all 2 articles
Browse latest View live


Latest Images