https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107238

            Bug ID: 107238
           Summary: aarch64: Wrong code converting pointer to __int128
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

For this testcase:

__int128 f(int *p) {
    return (__int128)p;
}

AArch64 GCC at -O2 generates:

f:
        asr     x1, x0, 63
        ret

i.e. it sign-extends the pointer, but I think it should be a zero extend
instead. The ABI [1] says:

> Code and data pointers are either 64-bit or 32-bit unsigned types.

Indeed LLVM does a zero-extend:

f:                                      // @f
        mov     x1, xzr
        ret

[1] :
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#pointers

Reply via email to