From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sourceware.org (Postfix) with ESMTPS id 4456F3857408 for ; Sun, 25 Jul 2021 12:20:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4456F3857408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=inria.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=inria.fr IronPort-HdrOrdr: =?us-ascii?q?A9a23=3Aa8YVoajQai4rFGifQZx7b+2I/3BQXuMji2hC?= =?us-ascii?q?6mlwRA09TyX4rbHWoB1/73XJYVkqOE3I9erwX5Voa0mslqKdmLNhX4tKPzOJhI?= =?us-ascii?q?LLFvAG0WKK+VSJcBEWndQtsZuIHZIObuEYzmIXsS852mSF+hobr+VvOZrIudvj?= X-IronPort-AV: E=Sophos;i="5.84,266,1620684000"; d="scan'208";a="521447552" Received: from 85-171-189-19.rev.numericable.fr (HELO hippo) ([85.171.189.19]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2021 14:19:59 +0200 Date: Sun, 25 Jul 2021 14:19:56 +0200 (CEST) From: Marc Glisse Reply-To: gcc@gcc.gnu.org To: =?ISO-8859-15?Q?Zolt=E1n_K=F3csi?= cc: gcc@gcc.gnu.org Subject: Re: An asm constraint issue (ARM FPU) In-Reply-To: <20210725123616.45126a97@mazsola> Message-ID: <9bd5681-fd38-7883-e06d-ca1c6b754a0@hippo.saclay.inria.fr> References: <20210725123616.45126a97@mazsola> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jul 2021 12:20:02 -0000 On Sun, 25 Jul 2021, Zoltán Kócsi wrote: > I try to write a one-liner inline function to create a double form > a 64-bit integer, not converting it to a double but the integer > containing the bit pattern for the double (type spoofing). > > The compiler is arm-eabi-gcc 8.2.0. > The target is a Cortex-A9, with NEON. > > According to the info page the assembler constraint "w" denotes an FPU > double register, d0 - d31. > > The code is the following: > > double spoof( uint64_t x ) > { > double r; > > asm volatile > ( > " vmov.64 %[d],%Q[i],%R[i] \n" Isn't it supposed to be %P[d] for a double? (the documentation is very lacking...) > : [d] "=w" (r) > : [i] "q" (x) > ); > > return r; > } > > The command line: > > arm-eabi-gcc -O0 -c -mcpu=cortex-a9 -mfloat-abi=hard -mfpu=neon-vfpv4 \ > test.c > > It compiles and the generated object code is this: > > 00000000 : > 0: e52db004 push {fp} ; (str fp, [sp, #-4]!) > 4: e28db000 add fp, sp, #0 > 8: e24dd014 sub sp, sp, #20 > c: e14b01f4 strd r0, [fp, #-20] ; 0xffffffec > 10: e14b21d4 ldrd r2, [fp, #-20] ; 0xffffffec > 14: ec432b30 vmov d16, r2, r3 > 18: ed4b0b03 vstr d16, [fp, #-12] > 1c: e14b20dc ldrd r2, [fp, #-12] > 20: ec432b30 vmov d16, r2, r3 > 24: eeb00b60 vmov.f64 d0, d16 > 28: e28bd000 add sp, fp, #0 > 2c: e49db004 pop {fp} ; (ldr fp, [sp], #4) > 30: e12fff1e bx lr > > which is not really efficient, but works. > > However, if I specify -O1, -O2 or -Os then the compilation fails > because assembler complains. This is the assembly the compiler > generated, (comments and irrelevant stuff removed): > > spoof: > vmov.64 s0,r0,r1 > bx lr > > where the problem is that 's0' is a single-precision float register and > it should be 'd0' instead. > > Either I'm seriously missing something, in which case I would be most > obliged if someone sent me to the right direction; or it is a compiler > or documentation bug. > > Thanks, > > Zoltan -- Marc Glisse