From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by sourceware.org (Postfix) with ESMTPS id 59969398B166 for ; Fri, 23 Oct 2020 15:05:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 59969398B166 Received: by mail-ej1-x644.google.com with SMTP id c15so2870589ejs.0 for ; Fri, 23 Oct 2020 08:05:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=dqtLQWaH8GZiycgkrTdFqIq4SjaTo7Bw88tDtPtlxMg=; b=tWV1lpnAB+hwddAFxbFSI9rRkcjNDsPb7o9e0djKgcxuTxkbiiv/k48P37DxeZFG6e naDqXPobv2x8Z7LA34GRF9uhBpp1w72vDBFnaFoGqJVt1Sh4seoxGfkDnMm06x8aaa7v JZWyvsIfvfM1MQkNI2IR+gipMjjnqJi1P9zs7d4uQHB7jWIOcaruXT3Ddik6Z2dwLLM8 51clPXnYWLj45ZSp07WdAqiogCSCZY33GUZdcjs8A/eTBuejROMuNDqFPr45L04XvG2O MPEk94a6kRbN9+s2LZQ67ZRkz0AtPaPS4QQqxiXdAKth3T7Q1n2bJBafxyc63LEUyZQO 2L2g== X-Gm-Message-State: AOAM533au+fQFDHtqDyxJugvSkqyYflq0BRjUmzxRnA1B+0G3f9FZeeO 8866b00ll00QuR6BDFCiGGhxMdlVXkc= X-Google-Smtp-Source: ABdhPJwbNdClJG4VaAb/XJXM47CPiMpd8YEdRzF13DaUeaVZBEaODCBmocpNmgjuUvYwZ7w+kaz8Gg== X-Received: by 2002:a17:906:e88:: with SMTP id p8mr2369713ejf.466.1603465554012; Fri, 23 Oct 2020 08:05:54 -0700 (PDT) Received: from [192.168.178.32] (dynamic-077-007-069-120.77.7.pool.telefonica.de. [77.7.69.120]) by smtp.gmail.com with ESMTPSA id b17sm887179edx.89.2020.10.23.08.05.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2020 08:05:52 -0700 (PDT) Date: Fri, 23 Oct 2020 17:05:49 +0200 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: move sincos after pre (was: Re: [Ada, FYI] revamp ada.numerics.aux) To: gcc-patches@gcc.gnu.org,Alexandre Oliva From: Richard Biener Message-ID: X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2020 15:05:57 -0000 On October 23, 2020 4:23:35 PM GMT+02:00, Alexandre Oliva wrote: >On Oct 22, 2020, Alexandre Oliva wrote: > >> On Oct 18, 2020, Alexandre Oliva wrote: >>> The option is provided by default, but there is an alternate version >>> that doesn't, that is used for vxworks targets=2E > >> vxworks float EFs not precise enough -> use long float > >> From: Alexandre Oliva > >> Some acats-4 tests that check the precision of Float elementary >> functions fail with vxworks 7=2E2's implementations of single-precision >> math functions=2E > >> This patch arranges for us to bypass the single-precision functions, >> and use the Aux_Long_Float implementation, based on the double-typed >> calls from the C library, for Float and Short_Float=2E > > >On platforms in which Aux_[Real_Type] involves non-NOP conversions >(e=2Eg=2E, between single- and double-precision, or between short float >and float), the conversions before the calls are CSEd too late for >sincos to combine calls=2E > >This patch moves sincos after PRE, where the conversions are unified >at -O2=2E > >I'm regstrapping this on x86_64-linux-gnu and powerpc64-linux-gnu, and >also testing it on affected platforms=2E Another way to go, that would >take a little more effort, would be to extend sincos to take equivalent >conversions as the same operand, but I doubt I'll be able to undertake >that any time soon, so=2E=2E=2E Is this one ok to install? Can you move it one pass further after sink please? Also I don't remember = exactly but does pass_sincos only handle sin/cos unifying?=20 Thanks,=20 Richard=2E=20 > >for gcc/ChangeLog > > * passes=2Edef: Move sincos after pre=2E > >for gcc/testsuite/ChangeLog > > * gnat=2Edg/sin_cos=2Eads: New=2E > * gnat=2Edg/sin_cos=2Eadb: New=2E > * gcc=2Edg/sin_cos=2Ec: New=2E >--- > gcc/passes=2Edef | 2 +- >gcc/testsuite/gcc=2Edg/sin_cos=2Ec | 41 >+++++++++++++++++++++++++++++++++++++ > gcc/testsuite/gnat=2Edg/sin_cos=2Eadb | 14 +++++++++++++ > gcc/testsuite/gnat=2Edg/sin_cos=2Eads | 4 ++++ > 4 files changed, 60 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc=2Edg/sin_cos=2Ec > create mode 100644 gcc/testsuite/gnat=2Edg/sin_cos=2Eadb > create mode 100644 gcc/testsuite/gnat=2Edg/sin_cos=2Eads > >diff --git a/gcc/passes=2Edef b/gcc/passes=2Edef >index cf15d8e=2E=2E2743506 100644 >--- a/gcc/passes=2Edef >+++ b/gcc/passes=2Edef >@@ -242,12 +242,12 @@ along with GCC; see the file COPYING3=2E If not >see > NEXT_PASS (pass_ccp, true /* nonzero_p */); > /* After CCP we rewrite no longer addressed locals into SSA > form if possible=2E */ >- NEXT_PASS (pass_cse_sincos); > NEXT_PASS (pass_optimize_bswap); > NEXT_PASS (pass_laddress); > NEXT_PASS (pass_lim); > NEXT_PASS (pass_walloca, false); > NEXT_PASS (pass_pre); >+ NEXT_PASS (pass_cse_sincos); > NEXT_PASS (pass_sink_code); > NEXT_PASS (pass_sancov); > NEXT_PASS (pass_asan); >diff --git a/gcc/testsuite/gcc=2Edg/sin_cos=2Ec >b/gcc/testsuite/gcc=2Edg/sin_cos=2Ec >new file mode 100644 >index 00000000=2E=2Ea4a7727 >--- /dev/null >+++ b/gcc/testsuite/gcc=2Edg/sin_cos=2Ec >@@ -0,0 +1,41 @@ >+/* { dg-do compile } */ >+/* { dg-options "-O2" } */ >+ >+/* This maps to essentially the same gimple that is generated for >+ gnat=2Edg/sin_cos=2Eadb, on platforms that use the wraplf variant of >+ Ada=2ENumerics=2EAux_Float=2E The value of EPSILON is not relevant t= o >+ the test, but the test must be there to keep the conversions in >+ different BBs long enough to trigger the problem that prevented the >+ sincos optimization, because the arguments passed to sin and cos >+ didn't get unified into a single SSA_NAME in time for sincos=2E */ >+ >+#include >+ >+#define EPSILON 3=2E4526697709225118160247802734375e-4 >+ >+static float my_sinf(float x) { >+ return (float) sin ((double) x); >+} >+ >+static float wrap_sinf(float x) { >+ if (fabs (x) < EPSILON) >+ return 0; >+ return my_sinf (x); >+} >+ >+static float my_cosf(float x) { >+ return (float) cos ((double) x); >+} >+ >+static float wrap_cosf(float x) { >+ if (fabs (x) < EPSILON) >+ return 1; >+ return my_cosf (x); >+} >+ >+float my_sin_cos(float x, float *s, float *c) { >+ *s =3D wrap_sinf (x); >+ *c =3D wrap_cosf (x); >+} >+ >+/* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* >*-w64-mingw* powerpc*-*-* } } } */ >diff --git a/gcc/testsuite/gnat=2Edg/sin_cos=2Eadb >b/gcc/testsuite/gnat=2Edg/sin_cos=2Eadb >new file mode 100644 >index 00000000=2E=2Ee72f521 >--- /dev/null >+++ b/gcc/testsuite/gnat=2Edg/sin_cos=2Eadb >@@ -0,0 +1,14 @@ >+-- { dg-do compile } >+-- { dg-options "-O2 -gnatn" } >+ >+with Ada=2ENumerics=2EElementary_Functions; >+use Ada=2ENumerics=2EElementary_Functions; >+package body Sin_Cos is >+ procedure Sin_Cos (Angle : T; SinA, CosA : out T) is >+ begin >+ SinA :=3D Sin (Angle); >+ CosA :=3D Cos (Angle); >+ end; >+end Sin_Cos; >+ >+-- { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* >*-w64-mingw* powerpc*-*-* } } } >diff --git a/gcc/testsuite/gnat=2Edg/sin_cos=2Eads >b/gcc/testsuite/gnat=2Edg/sin_cos=2Eads >new file mode 100644 >index 00000000=2E=2Ea0eff3d >--- /dev/null >+++ b/gcc/testsuite/gnat=2Edg/sin_cos=2Eads >@@ -0,0 +1,4 @@ >+package Sin_Cos is >+ subtype T is Float; >+ procedure Sin_Cos (Angle : T; SinA, CosA : out T); >+end Sin_Cos;