On 10 March 2016 at 19:52, Yvan Roux yvan.roux@linaro.org wrote:
On 10 March 2016 at 19:42, Edward Nevill edward.nevill@linaro.org wrote:
/usr/local/linare-gcc-5.2/bin/gcc -S -O3 -march=armv8-a+lse test.c
add_int: ldaddal w0, w0, [x1] add w2, w0, w0 mov w0, w2 ret
Am I going mad, or does this just return the contents of the memory location * 2.
ldaddal w0, w0, [x1]
Returns the original contents of [x1] in w0.
add w2, w0, w0
doubles it.
mov w0, w2
returns it.
I think __sync_add_and_fetch should return the updated contents.
Here is the test C code again.
int add_int(int add_value, int *dest) { return __sync_add_and_fetch(dest, add_value); }
Hmm, it is not the code I get with our latest release candidate (the release should be out next week), it gives the code:
add_int: ldaddal w0, w3, [x1] add w2, w3, w0 mov w0, w2 ret
Ed, just for info it was fixed by Andrew in trunk and backported in our branch end of December.
https://gcc.gnu.org/ml/gcc-patches/2015-12/msg01962.html
Regards, Ed.