Re: Inline assembly and value extensions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/10/2020 14:29, Florian Weimer wrote:
* Harald van Dijk via Gcc-help:

In the x32 ABI, pointers do not have a single mode. They are SImode,
except when passed as parameters or returned, in which case they are
DImode (see the ix86_promote_function_mode function I mentioned). This
is really the source of the problems.

I think that GCC cannot optimize away unecessary sign and zero
extensions is also a contributing factor, no?

Hmm, yes, that is a good point too. An ugly way to try to inform GCC that the extension is unnecessary would be

  void *return_a_pointer(void) {
    unsigned long long result;
    asm("movl $0x11223344, %%eax" : "=a"(result));
    if (result & 0xFFFFFFFF00000000ULL)
      __builtin_unreachable();
    return (void *)result;
  }

This is not something I would want to have to write explicitly, but it does not help anyway at the moment, even in this case GCC emits the extra extension: <https://godbolt.org/z/vPb1Mr>. I think here the code does give enough information to GCC that it could in theory optimize it away.

(clang does not emit the extra extension, but that is because LLVM implements this ABI incorrectly, so not a fair comparison. I hope to be able to submit a patch to them for that at some later time.)



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux