public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/107238] New: aarch64: Wrong code converting pointer to __int128
@ 2022-10-12 16:25 acoplan at gcc dot gnu.org
  2022-10-12 23:21 ` [Bug target/107238] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: acoplan at gcc dot gnu.org @ 2022-10-12 16:25 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/107238] aarch64: Wrong code converting pointer to __int128
  2022-10-12 16:25 [Bug target/107238] New: aarch64: Wrong code converting pointer to __int128 acoplan at gcc dot gnu.org
@ 2022-10-12 23:21 ` pinskia at gcc dot gnu.org
  2022-10-12 23:25 ` pinskia at gcc dot gnu.org
  2022-10-13  0:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-12 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Arrays-and-pointers-implementation.html#Arrays-and-pointers-implementation

> A cast from integer to pointer discards most-significant bits if the pointer representation is smaller than the integer type, extends according to the signedness of the integer type if the pointer representation is larger than the integer type, otherwise the bits are unchanged.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/107238] aarch64: Wrong code converting pointer to __int128
  2022-10-12 16:25 [Bug target/107238] New: aarch64: Wrong code converting pointer to __int128 acoplan at gcc dot gnu.org
  2022-10-12 23:21 ` [Bug target/107238] " pinskia at gcc dot gnu.org
@ 2022-10-12 23:25 ` pinskia at gcc dot gnu.org
  2022-10-13  0:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-12 23:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang does not even define the behavior here even though it should be as it is
an implementation defined behavior.
File a bug with clang about not documenting their behavior ...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/107238] aarch64: Wrong code converting pointer to __int128
  2022-10-12 16:25 [Bug target/107238] New: aarch64: Wrong code converting pointer to __int128 acoplan at gcc dot gnu.org
  2022-10-12 23:21 ` [Bug target/107238] " pinskia at gcc dot gnu.org
  2022-10-12 23:25 ` pinskia at gcc dot gnu.org
@ 2022-10-13  0:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-13  0:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> File a bug with clang about not documenting their behavior ...

Oh there is one already:
https://github.com/llvm/llvm-project/issues/11644
Still open after (almost) 10 years.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-13  0:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 16:25 [Bug target/107238] New: aarch64: Wrong code converting pointer to __int128 acoplan at gcc dot gnu.org
2022-10-12 23:21 ` [Bug target/107238] " pinskia at gcc dot gnu.org
2022-10-12 23:25 ` pinskia at gcc dot gnu.org
2022-10-13  0:12 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).