Optimization with inline assembly

Marcel Keller m.keller@bristol.ac.uk
Mon Aug 14 20:39:00 GMT 2017


Hi,

I've found that the attached code behaves differently when compiling 
with or without -O in GCC 7.2.

$ gcc asm.cpp ; ./a.out
1
$ gcc -O asm.cpp ; ./a.out
0

Looking at the compiled program in the second case, GCC seems to omit 
the inline assembly:

00000000004004e7 <f(long*)>:
   4004e7:	f3 c3                	repz retq

My understanding is that the "memory" cobbler should tell GCC to assume 
that the assembly changes the memory (which it does). Am I missing 
something here?

Best regards,
Marcel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: asm.cpp
Type: text/x-c++src
Size: 287 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20170814/3a86bf8e/attachment.bin>


More information about the Gcc-help mailing list