This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: i386/asm-4 test: use amd64's natural addressing mode on all OSs
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Alexandre Oliva <oliva at adacore dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>, Rainer Orth <ro at cebitec dot uni-bielefeld dot de>, Mike Stump <mikestump at comcast dot net>
- Date: Thu, 15 Aug 2019 14:50:57 +0200
- Subject: Re: i386/asm-4 test: use amd64's natural addressing mode on all OSs
- References: <ork1beirot.fsf@lxoliva.fsfla.org>
On Thu, Aug 15, 2019 at 1:39 PM Alexandre Oliva <oliva@adacore.com> wrote:
>
> gcc.target/i386/asm-4.c uses amd64's natural PC-relative addressing
> mode on a single platform, using the 32-bit absolute addressing mode
> elsewhere. There's no point in giving up amd64's natural addressing
> mode and insisting on the 32-bit one when we're targeting amd64, and
> having to make explicit exceptions for systems where that's found not
> to work for whatever reason. If we just use the best-suited way to
> take the address of a function behind the compiler's back on each
> target variant, we're less likely to hit unexpected failures.
>
> Tested on x86_64-linux-gnu with unix{,-m32}. Ok to install?
Perhaps we should use true absolute address:
--cut here--
Index: asm-4.c
===================================================================
--- asm-4.c (revision 274504)
+++ asm-4.c (working copy)
@@ -27,12 +27,10 @@
void
baz (void)
{
- /* Darwin loads 64-bit regions above the 4GB boundary so
- we need to use this instead. */
-#if defined (__LP64__) && defined (__MACH__)
- __asm ("leaq foo(%%rip), %0" : "=r" (fn));
+#if defined (__LP64__)
+ __asm ("movabsq $foo, %0" : "=r" (fn));
#else
- __asm ("movl $foo, %k0" : "=r" (fn));
+ __asm ("movl $foo, %0" : "=r" (fn));
#endif
if (fn (2, 3, 4, 5) != 14)
abort ();
--cut here--
Uros.