[arm64] Negative immediates

Marc Glisse marc.glisse at inria.fr
Tue Sep 23 21:20:31 UTC 2014


On Mon, 22 Sep 2014, Torbjörn Granlund wrote:

>  Note that count_leading_zeros_gcc_clz seems to work just fine, we
>  could use that instead.
> 
> Have you tried both gcc and clang for correctness and code quality?

long f(long l){return __builtin_clzl(l);}

compiles to:

 	clz	x0, x0
 	ret

with clang-3.4, clang-3.5, gcc-4.8 and gcc-4.9 at -O or higher (-O0 also 
calls clz, with some loads and stores around it).

>  On aarch64, with "r"(var), gcc and clang always name the register x0
>  (never w0), whether var is an int or a long long. On amd64, I get %al
>  / %ax / %eax / %rax depending on the type of var.
>
> You're right!  That seem quite odd, I'd say wrong, and is why things
> happens to work with gcc.
>
> (One can override it with 'w' after the % in the register constraint.
> See aarch64_print_operand in gcc-4.8.2/gcc/config/aarch64/aarch64.c.)

Nice find, but clang doesn't accept it. I'll ask the gcc devs.

-- 
Marc Glisse


More information about the gmp-bugs mailing list