From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.gigawatt.nl (mail.gigawatt.nl [IPv6:2001:41d0:801:2000::19e9]) by sourceware.org (Postfix) with ESMTPS id 9EB2D3857802 for ; Mon, 5 Oct 2020 13:39:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9EB2D3857802 Received: from [192.168.1.8] (hvdijk.plus.com [81.174.157.28]) by mail.gigawatt.nl (Postfix) with ESMTPSA id 1AEE13C0; Mon, 5 Oct 2020 15:39:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.gigawatt.nl 1AEE13C0 Subject: Re: Inline assembly and value extensions To: Florian Weimer , gcc-help@gcc.gnu.org Cc: Segher Boessenkool References: <8985cc81-573c-b011-4e02-aa9829524133@gigawatt.nl> <3c338ceb-1dfa-5c15-8295-5b5a7dd4bad7@gigawatt.nl> <20201005125328.GA2672@gate.crashing.org> <87ft6sx0lt.fsf@oldenburg2.str.redhat.com> From: Harald van Dijk Message-ID: <4f53960b-f5ed-e61f-fdc6-d6ac7b070e24@gigawatt.nl> Date: Mon, 5 Oct 2020 14:39:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.1.1 MIME-Version: 1.0 In-Reply-To: <87ft6sx0lt.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Oct 2020 13:39:56 -0000 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: . 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.)