Closed lIIIIIIIIl closed 3 years ago
Looking into this.
I think I had similar issue earlier and may have fixed it in some other project of mine already.
Changing it into "re" or "rZ" or "reZ" works for me so far.
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
So I looked into this and it seems to compile just fine on godbolt with clang and gcc, but it does seem to be broken on clang-cl on my machine. I'd say this is probably a compiler bug.
Furthermore the e
and Z
constraints don't really make sense since your value is not something that fits into 32 bits and is being sign extended, however it still generates correct assembly so :shrug:
I tested just replacing "rn" with "reZ" on my private projects (with clang-cl that is broken in this case) and it seemed to not change codegen in any way on a release build.
Will probably make the change, although I'm a bit afraid I might break it on actual clang/gcc.
Sorry I don't really understand how constraints works. I was typing random letters into the constraints string. "re" and "rZ" and "reZ" are the only ones I found that works so far for this instruction movq %[x], 48(%%rsp)
https://godbolt.org/z/6jbrWW
Do you happen to know any good tutorial on how to write gcc extended asm, or assembly in general?
Should be fixed.
Concerning the learning part I learned assembly mostly trough experience reading about instructions when debugging with tools like x64dbg and for extended asm the GCC docs for it are pretty good
I think it needs to be "re", not "reZ". https://godbolt.org/z/6cfYnc
Changed it
I believe it has something to do with the input constraint "rn", because if I change it to "r", then it compiles.