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.133.124]) by sourceware.org (Postfix) with ESMTPS id D7B0E385802B for ; Fri, 7 Jan 2022 13:31:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D7B0E385802B 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-460-MBsM21NEP0m0WaE9fyHPUQ-1; Fri, 07 Jan 2022 08:31:10 -0500 X-MC-Unique: MBsM21NEP0m0WaE9fyHPUQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09279104ECFC; Fri, 7 Jan 2022 13:31:09 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.2.16.169]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D3D810A3BC2; Fri, 7 Jan 2022 13:31:08 +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 207DV5YR2752675 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 7 Jan 2022 14:31:05 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 207DV34V2752674; Fri, 7 Jan 2022 14:31:03 +0100 Date: Fri, 7 Jan 2022 14:31:03 +0100 From: Jakub Jelinek To: Thomas Koenig Cc: Michael Meissner , Segher Boessenkool , "fortran@gcc.gnu.org" , Peter Bergner , gcc-patches@gcc.gnu.org, Bill Schmidt , David Edelsohn Subject: Re: [power-ieee128] RFH: LTO broken Message-ID: <20220107133103.GN2664@tucnak> Reply-To: Jakub Jelinek References: <20220103153621.GL2664@tucnak> <20220103162650.GV2646553@tucnak> <20220103200026.GW2646553@tucnak> <1bd479f6-2ea6-a19d-b8e5-69d3cac7ca98@netcologne.de> <20220104110749.GC2646553@tucnak> <20220107112923.GJ2646553@tucnak> MIME-Version: 1.0 In-Reply-To: <20220107112923.GJ2646553@tucnak> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable 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: Fri, 07 Jan 2022 13:31:15 -0000 On Fri, Jan 07, 2022 at 12:29:25PM +0100, Jakub Jelinek wrote: > we don't do it consistently: > readelf -Wr /home/jakub/gcc/obj38/powerpc64le-unknown-linux-gnu/libgfortran/.libs/libgfortran.so.5.0.0 | grep ieee128 > 0000000000250310 0000012800000015 R_PPC64_JMP_SLOT 0000000000000000 __atan2ieee128 + 0 > 0000000000250340 0000014200000015 R_PPC64_JMP_SLOT 0000000000000000 __clogieee128 + 0 > 0000000000250438 000001a300000015 R_PPC64_JMP_SLOT 0000000000000000 __acoshieee128 + 0 > 00000000002504b8 000001cc00000015 R_PPC64_JMP_SLOT 0000000000000000 __csinieee128 + 0 > 0000000000250500 000001f300000015 R_PPC64_JMP_SLOT 0000000000000000 __sinhieee128 + 0 > 0000000000250570 0000022a00000015 R_PPC64_JMP_SLOT 0000000000000000 __asinieee128 + 0 > 0000000000250580 0000022d00000015 R_PPC64_JMP_SLOT 0000000000000000 __roundieee128 + 0 > 00000000002505a0 0000023e00000015 R_PPC64_JMP_SLOT 0000000000000000 __logieee128 + 0 > 00000000002505c8 0000024900000015 R_PPC64_JMP_SLOT 0000000000000000 __tanieee128 + 0 > 0000000000250630 0000027500000015 R_PPC64_JMP_SLOT 0000000000000000 __ccosieee128 + 0 > 0000000000250670 0000028a00000015 R_PPC64_JMP_SLOT 0000000000000000 __log10ieee128 + 0 > 00000000002506c8 000002bd00000015 R_PPC64_JMP_SLOT 0000000000000000 __cexpieee128 + 0 > 00000000002506d8 000002c800000015 R_PPC64_JMP_SLOT 0000000000000000 __coshieee128 + 0 > 00000000002509b0 000003ef00000015 R_PPC64_JMP_SLOT 0000000000000000 __truncieee128 + 0 > 0000000000250af8 000004a600000015 R_PPC64_JMP_SLOT 0000000000000000 __expieee128 + 0 > 0000000000250b50 000004c600000015 R_PPC64_JMP_SLOT 0000000000000000 __fmodieee128 + 0 > 0000000000250bb0 000004e700000015 R_PPC64_JMP_SLOT 0000000000000000 __tanhieee128 + 0 > 0000000000250c38 0000051300000015 R_PPC64_JMP_SLOT 0000000000000000 __acosieee128 + 0 > 0000000000250ce0 0000055400000015 R_PPC64_JMP_SLOT 0000000000000000 __sinieee128 + 0 > 0000000000250d60 0000057e00000015 R_PPC64_JMP_SLOT 0000000000000000 __atanieee128 + 0 > 0000000000250dd8 000005b100000015 R_PPC64_JMP_SLOT 0000000000000000 __sqrtieee128 + 0 > 0000000000250e98 0000060200000015 R_PPC64_JMP_SLOT 0000000000000000 __cosieee128 + 0 > 0000000000250eb0 0000060a00000015 R_PPC64_JMP_SLOT 0000000000000000 __atanhieee128 + 0 > 0000000000250ef0 0000062000000015 R_PPC64_JMP_SLOT 0000000000000000 __asinhieee128 + 0 > 0000000000250fd8 0000067f00000015 R_PPC64_JMP_SLOT 0000000000000000 __csqrtieee128 + 0 > 0000000000251038 000006ad00000015 R_PPC64_JMP_SLOT 0000000000000000 __cabsieee128 + 0 > All these should for POWER_IEEE128 use atan2q@QUADMATH_1.0 etc. So, seems all these come from f951 compiled sources. For user code, I think the agreement was if you want to use successfully -mabi=ieeelongdouble, you need glibc 2.32 or later, which is why the Fortran FE doesn't conditionalize on whether glibc 2.32 is available or not and just emits __WHATEVERieee128 entrypoints. But for Fortran compiled sources in libgfortran, we need to use __WHATEVERieee128 only if glibc 2.32 or later and WHATEVERq (from libquadmath) otherwise. I guess easiest would be to do this always in the FE, but we need to determine in the FE if the target is glibc 2.32 or later. > On the other side, on glibc 2.32+ build, we still use some libquadmath APIs > when we shouldn't: > readelf -Wr /home/jakub/gcc/obj/powerpc64le-unknown-linux-gnu/libgfortran/.libs/libgfortran.so.5 | grep QUADMATH > 00000000002502c8 0000002600000015 R_PPC64_JMP_SLOT 0000000000000000 fmaq@QUADMATH_1.0 + 0 > 00000000002505f8 0000006700000015 R_PPC64_JMP_SLOT 0000000000000000 tanq@QUADMATH_1.0 + 0 > 0000000000250930 0000009b00000015 R_PPC64_JMP_SLOT 0000000000000000 fabsq@QUADMATH_1.0 + 0 > 0000000000250940 0000009d00000015 R_PPC64_JMP_SLOT 0000000000000000 sinq@QUADMATH_1.0 + 0 > 0000000000250c98 000000cf00000015 R_PPC64_JMP_SLOT 0000000000000000 copysignq@QUADMATH_1.0 + 0 > 0000000000251038 0000010700000015 R_PPC64_JMP_SLOT 0000000000000000 cosq@QUADMATH_1.0 + 0 > 0000000000251068 0000010a00000015 R_PPC64_JMP_SLOT 0000000000000000 fmodq@QUADMATH_1.0 + 0 > These should use __fmaieee128, __tanieee128 etc. instead. This one seems easily fixed by the following patch, ok for power-ieee128? 2022-01-07 Jakub Jelinek * libgfortran.h (__copysignieee128, __fmaieee128, __fmodieee128): Declare. * intrinsics/trigd.c (COPYSIGN, FMOD, FABS, FMA, SIN, COS, TAN): If POWER_IEEE128 is defined, define these for kind 17 include. * intrinsics/trigd_lib.inc (COPYSIGN, FMOD, FABS, FMA, SIN, COS, TAN): Don't define if COPYSIGN is already defined. --- libgfortran/libgfortran.h.jj 2022-01-07 09:39:10.222157644 +0000 +++ libgfortran/libgfortran.h 2022-01-07 12:58:57.604483761 +0000 @@ -1956,6 +1956,8 @@ extern __float128 __atanhieee128 (__floa __attribute__ ((__nothrow__, __leaf__)); extern __float128 __atanieee128 (__float128) __attribute__ ((__nothrow__, __leaf__)); +extern __float128 __copysignieee128 (__float128, __float128) + __attribute__ ((__nothrow__, __leaf__)); extern __float128 __coshieee128 (__float128) __attribute__ ((__nothrow__, __leaf__)); extern __float128 __cosieee128 (__float128) @@ -1968,6 +1970,10 @@ extern __float128 __expieee128 (__float1 __attribute__ ((__nothrow__, __leaf__)); extern __float128 __fabsieee128 (__float128) __attribute__ ((__nothrow__, __leaf__)); +extern __float128 __fmaieee128 (__float128, __float128, __float128) + __attribute__ ((__nothrow__, __leaf__)); +extern __float128 __fmodieee128 (__float128, __float128) + __attribute__ ((__nothrow__, __leaf__)); extern __float128 __jnieee128 (int, __float128) __attribute__ ((__nothrow__, __leaf__)); extern __float128 __log10ieee128 (__float128) --- libgfortran/intrinsics/trigd.c.jj 2022-01-07 09:39:10.222157644 +0000 +++ libgfortran/intrinsics/trigd.c 2022-01-07 12:57:01.311939084 +0000 @@ -313,6 +313,16 @@ see the files COPYING3 and COPYING.RUNTI #define HAVE_INFINITY_KIND #endif +#ifdef POWER_IEEE128 +#define COPYSIGN __copysignieee128 +#define FMOD __fmodieee128 +#define FABS __fabsieee128 +#define FMA __fmaieee128 +#define SIN __sinieee128 +#define COS __cosieee128 +#define TAN __tanieee128 +#endif + #include "trigd_lib.inc" #undef KIND --- libgfortran/intrinsics/trigd_lib.inc.jj 2021-12-31 11:00:58.083137032 +0000 +++ libgfortran/intrinsics/trigd_lib.inc 2022-01-07 12:56:25.491155265 +0000 @@ -65,6 +65,7 @@ PIO180L -- lower bits of p #define CONCAT(x,y) x ## y #define CONCAT_EXPAND(x,y) CONCAT(x,y) +#ifndef COPYSIGN #define COPYSIGN LITERAL(copysign) #define FMOD LITERAL(fmod) #define FABS LITERAL(fabs) @@ -72,6 +73,7 @@ PIO180L -- lower bits of p #define SIN LITERAL(sin) #define COS LITERAL(cos) #define TAN LITERAL(tan) +#endif #ifdef TINY #define TINY_LITERAL LITERAL(TINY) Jakub