From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id A7ABF3858D20 for ; Sun, 11 Jun 2023 02:04:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7ABF3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5148e4a2f17so5556425a12.1 for ; Sat, 10 Jun 2023 19:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686449073; x=1689041073; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9gIOw2M4TJjP8jQu9phYzrQoIvv+8fK13cTc7sUlJdg=; b=pTPDmEzIOfF3XVW8Uxz45L5pZnjC88zVtxhl09ArViywv1cxKe0Zojh/jSNt+QVJ9S DV+Bx5WxNlJIteJgUzSb3yBtLRbngfo0XUGaAJPHAZkiivo0wLk2kIyfJMSk2JQhINov sWeFycNDRvgRMWKGunLiHQOOIlJf/7jBvwkn1rQcyhU1tMrybSrHCNx6v1K1lnc1s/ip /xNPvlp+DB5vHaqLpN8KQk3tu5ZLAyqCYnlMbGhwwnlZLit1G/y+0EigoXoqR6ZiorqE NdDftwWEcR9dfTmGEJL/2GsxbQbrdKhY96iU0QlULG2LOBGmESgrZvpp3N4RNr2DnI4u nyNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686449073; x=1689041073; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9gIOw2M4TJjP8jQu9phYzrQoIvv+8fK13cTc7sUlJdg=; b=d4h+eH4KQROruEa9XClphNyloxE1gXRS+gNEwTnI1/s0ZJBpPBjPWakuwYeBBZdJzX aHPj3I4h5YqioXeYh6yKVmDz9rH596bWTfAnbVLr76cpi2kWcnoiU/ApmgcCZB1XgG+5 cGSmCOeatTAiZ2s50UfuwmN53pKpHL0MDutru53NwWRliHcHjGzpzF45Ct3st3WP2IFq jkRPmIy5F7mFZuFijm6T7uSjVYXNNJaRRdSNBOIo94pZ4EYFWoQvol+kgrENW+lffN++ spQwNYUAR1riKg9FQsfEVDOOJGLk1ZX3qRvzGvvMfVcRPV5B1bEnuIpr1Em6B92hDeKq FDMw== X-Gm-Message-State: AC+VfDzLrJTof+MbJrbbRJOetALGQoY6NtOQYjbeMLIzE/FPXX5aFSku UbPn2hA4zv97lXu5z9NR1o7+m2+6GhZ9ze/G2wo5wCwT X-Google-Smtp-Source: ACHHUZ7gCctOUHftwHGlHI0MJ9pF5HFXCGoiwqoYv9WJhP86BsBOTJWVFD6cGxMpbagUoZ27sNWrujJd/S3/Yxtbdak= X-Received: by 2002:a17:907:6d23:b0:96f:b8a0:6cfe with SMTP id sa35-20020a1709076d2300b0096fb8a06cfemr6066006ejc.54.1686449073301; Sat, 10 Jun 2023 19:04:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Edelsohn Date: Sat, 10 Jun 2023 22:04:21 -0400 Message-ID: Subject: Re: [PATCH] rs6000: Don't use TFmode for 128 bits fp constant in toc [PR110011] To: "Kewen.Lin" Cc: GCC Patches , Segher Boessenkool , Peter Bergner Content-Type: multipart/alternative; boundary="000000000000f22bb505fdd105a7" X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000f22bb505fdd105a7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 6, 2023 at 5:20=E2=80=AFAM Kewen.Lin wrot= e: > Hi, > > As PR110011 shows, when encoding 128 bits fp constant into > toc, we adopts REAL_VALUE_TO_TARGET_LONG_DOUBLE which is > to find the first float mode with LONG_DOUBLE_TYPE_SIZE > bits of precision, it would be TFmode here. But the 128 > bits fp constant can be with mode IFmode or KFmode, which > doesn't necessarily have the same underlying float format > as the one of TFmode, like this PR exposes, with option > -mabi=3Dibmlongdouble TFmode has ibm_extended_format while > KFmode has ieee_quad_format, mixing up the formats (the > encoding/decoding ways) would cause unexpected results. > > This patch is to make it use constant's own mode instead > of TFmode for real_to_target call. > > Bootstrapped and regtested on powerpc64-linux-gnu P7/P8/P9 and > powerpc64le-linux-gnu P9 and P10. > > I'll push this next week if no objections. > > BR, > Kewen > ----- > PR target/110011 > > gcc/ChangeLog: > > * config/rs6000/rs6000.cc (output_toc): Use its own mode of the > 128-bit float constant for real_to_target call. > The comment wording can be worded better. Maybe Use the mode of the 128-bit floating constant itself for real_to_target call. This is okay. Thanks, David > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/pr110011.c: New test. > --- > gcc/config/rs6000/rs6000.cc | 2 +- > gcc/testsuite/gcc.target/powerpc/pr110011.c | 42 +++++++++++++++++++++ > 2 files changed, 43 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/pr110011.c > > diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc > index 3f129ea37d2..330c6a6fa5f 100644 > --- a/gcc/config/rs6000/rs6000.cc > +++ b/gcc/config/rs6000/rs6000.cc > @@ -17314,7 +17314,7 @@ output_toc (FILE *file, rtx x, int labelno, > machine_mode mode) > if (DECIMAL_FLOAT_MODE_P (GET_MODE (x))) > REAL_VALUE_TO_TARGET_DECIMAL128 (*CONST_DOUBLE_REAL_VALUE (x), k); > else > - REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), k= ); > + real_to_target (k, CONST_DOUBLE_REAL_VALUE (x), GET_MODE (x)); > > if (TARGET_64BIT) > { > diff --git a/gcc/testsuite/gcc.target/powerpc/pr110011.c > b/gcc/testsuite/gcc.target/powerpc/pr110011.c > new file mode 100644 > index 00000000000..5b04d3e298a > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/pr110011.c > @@ -0,0 +1,42 @@ > +/* { dg-do run } */ > +/* { dg-require-effective-target float128_runtime } */ > +/* Force long double to be with IBM format here, to verify > + _Float128 constant still uses its own format (IEEE) for > + encoding rather than IBM format. */ > +/* { dg-options "-mfp-in-toc -mabi=3Dibmlongdouble" } */ > +/* { dg-add-options float128 } */ > + > +#define MPFR_FLOAT128_MAX 0x1.ffffffffffffffffffffffffffffp+16383f128 > + > +__attribute__ ((noipa)) > +_Float128 f128_max () > +{ > + return MPFR_FLOAT128_MAX; > +} > + > +typedef union > +{ > + int w[4]; > + _Float128 f128; > +} U; > + > +int main () > +{ > + > + U umax; > + umax.f128 =3D f128_max (); > + /* ieee float128 max: > + 7ffeffff ffffffff ffffffff ffffffff. */ > + if (umax.w[1] !=3D 0xffffffff || umax.w[2] !=3D 0xffffffff) > + __builtin_abort (); > +#ifdef __LITTLE_ENDIAN__ > + if (umax.w[0] !=3D 0xffffffff || umax.w[3] !=3D 0x7ffeffff) > + __builtin_abort (); > +#else > + if (umax.w[3] !=3D 0xffffffff || umax.w[0] !=3D 0x7ffeffff) > + __builtin_abort (); > +#endif > + > + return 0; > +} > + > -- > 2.31.1 > --000000000000f22bb505fdd105a7--