From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 600383858401 for ; Sat, 8 Jan 2022 14:03:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 600383858401 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-zl_CggbXNbSPL3KZApbKbQ-1; Sat, 08 Jan 2022 09:03:07 -0500 X-MC-Unique: zl_CggbXNbSPL3KZApbKbQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC25E839A42; Sat, 8 Jan 2022 14:03:04 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 083D12B59F; Sat, 8 Jan 2022 14:03:03 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 208E30W11076278 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 8 Jan 2022 15:03:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 208E2w301076277; Sat, 8 Jan 2022 15:02:58 +0100 Date: Sat, 8 Jan 2022 15:02:58 +0100 From: Jakub Jelinek To: Thomas Koenig , Michael Meissner , Segher Boessenkool , "fortran@gcc.gnu.org" , Peter Bergner , Bill Schmidt , gcc-patches@gcc.gnu.org, David Edelsohn Subject: Re: [power-ieee128] OPEN CONV Message-ID: <20220108140258.GU2646553@tucnak> Reply-To: Jakub Jelinek References: <20220107092202.GE2646553@tucnak> <28f0a876-7281-936d-f727-cb7067c052f9@netcologne.de> <20220107195220.GP2646553@tucnak> <332da363-1c64-e1bf-a05a-d412c600f580@netcologne.de> <20220107214813.GR2646553@tucnak> <124cfb8a-e3d0-207c-8dcb-bdfab29372cb@netcologne.de> <20220108110038.GS2646553@tucnak> <20220108111056.GT2646553@tucnak> MIME-Version: 1.0 In-Reply-To: <20220108111056.GT2646553@tucnak> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_MANYTO, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jan 2022 14:03:13 -0000 On Sat, Jan 08, 2022 at 12:10:56PM +0100, Jakub Jelinek via Gcc-patches wrote: > One reason for that is that neither conversion is lossless, neither format > is a subset or superset of the other. Yes, IEEE quad has both much bigger > exponent range (-16382..16383 vs. -1022..1023) and slightly bigger fixed > precision (113 vs. 106 bits). > But IBM extended has that weirdo numerically awful flexible precision where > certain numbers can have much bigger precision than those 106 bits, up to > 2048+52 or so. So there is rounding in both directions. > So, after distros switch to -mabi=ieeelongdouble by default or when people > use -mabi=ieeelongdouble on their programs, they'd better store that format > into data files by default, without the need of some magic CONVERT= options, > env vars or command line options. Only in the case where they need to > interact with -mabi=ibmlongdouble environments, they need to take some > action. Note, as for byteswapping, apparently it wasn't ever working right fox the IBM extended real(kind=16) and complex(kind=16). Because unlike IEEE extended or integral types, it seems powerpc*-*-* doesn't actually fully byteswap those between little and big endian. Proof: long double a = 0.3333333333333333333333333333333333333333333333333333333333333333333333333333L; compiled little endian IBM long double: .size a, 16 a: .long 1431655765 .long 1070945621 .long 1431655766 .long 1014322517 compiled big endian IBM long double: .size a, 16 a: .long 1070945621 .long 1431655765 .long 1014322517 .long 1431655766 compiled little endian IEEE long double: .size a, 16 a: .long 1431655765 .long 1431655765 .long 1431655765 .long 1073567061 compiled big endian IEEE long double: .size a, 16 a: .long 1073567061 .long 1431655765 .long 1431655765 .long 1431655765 where the numbers in .long arguments are 32-bit numbers stored in the selected endianity. Compiled with -mlong-double-64 little endian: .size a, 8 a: .long 1431655765 .long 1070945621 and big endian: .size a, 8 a: .long 1070945621 .long 1431655765 Unless I'm misreading this, for IEEE long double, or double (and I bet float too) byteswapping the whole numbers is what is needed for interoperability between powerpc64{,le}-linux, for IBM long double we'd actually want to byteswap it as 2 real(kind=8) numbers and not one real(kind=16) one, i.e. the numbers are always stored as the more significant double followed by less significant double in memory. Jakub