From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28337 invoked by alias); 17 May 2016 21:23:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 28324 invoked by uid 89); 17 May 2016 21:23:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=HX-Envelope-From:sk:pinskia, sum X-HELO: mail-lf0-f54.google.com Received: from mail-lf0-f54.google.com (HELO mail-lf0-f54.google.com) (209.85.215.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 17 May 2016 21:22:59 +0000 Received: by mail-lf0-f54.google.com with SMTP id m64so12268275lfd.1 for ; Tue, 17 May 2016 14:22:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=0vrYPan4aa+tIxn5Qm7h9x+tNcHgJ4iKRLLl6HKOO5c=; b=NexgsSe9FmhdYV9Fqldb6o8fP30oMnw6tXF4A4ChQbJHNew1g4zNsyA5im9sLlG7ah BynPPmOgBc2xefmY8Sjt72l/PgcV3IqBu9pIHbrs6FoxCrxtrhzScwrtoJeHBBFK2BEc V3qie8vh6RjdQQ08auDEUgdBnADG69WSWOrADsRg+6+tX6SCZPCbF8TOVuIqM3AeVcQE MOjF2hU5ppRdT+ZSx15PN3Przr8T1bQficyJ+xQOoXFJyOwGcs5DfUJKhXdM0+pVCirG dD88v4qPi5yr8ct98mdIJ7yRWjtAate7VoD7gdhhRFwhhUbXUWHN91CcULkGW6vuvSe7 +CAQ== X-Gm-Message-State: AOPr4FUUUmVhlKSVh0MDM+RMExH4QIMVH//GRkCyJ2IgdTpnPTEG9+2pKQ/S1PjXAXSm8kDr6HTOosY0ZKkfNQ== MIME-Version: 1.0 X-Received: by 10.25.196.20 with SMTP id u20mr1330568lff.164.1463520176037; Tue, 17 May 2016 14:22:56 -0700 (PDT) Received: by 10.25.16.222 with HTTP; Tue, 17 May 2016 14:22:55 -0700 (PDT) In-Reply-To: <573B88B0.2080508@codesourcery.com> References: <573628A1.1030501@codesourcery.com> <862033F1-A268-4236-B908-558C102199B5@gmail.com> <573B88B0.2080508@codesourcery.com> Date: Tue, 17 May 2016 21:23:00 -0000 Message-ID: Subject: Re: inhibit the sincos optimization when the target has sin and cos instructions From: Andrew Pinski To: Cesar Philippidis Cc: Richard Biener , Nathan Sidwell , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg01284.txt.bz2 On Tue, May 17, 2016 at 2:10 PM, Cesar Philippidis wrote: > On 05/13/2016 01:13 PM, Andrew Pinski wrote: >> On Fri, May 13, 2016 at 12:58 PM, Richard Biener >> wrote: >>> On May 13, 2016 9:18:57 PM GMT+02:00, Cesar Philippidis wrote: >>>> The cse_sincos pass tries to optimize sequences such as >>>> >>>> sin (x); >>>> cos (x); >>>> >>>> into a single call to sincos, or cexpi, when available. However, the >>>> nvptx target has sin and cos instructions, albeit with some loss of >>>> precision (so it's only enabled with -ffast-math). This patch teaches >>>> cse_sincos pass to ignore sin, cos and cexpi instructions when the >>>> target can expand those calls. This yields a 6x speedup in 314.omriq >>> >from spec accel when running on Nvidia accelerators. >>>> >>>> Is this OK for trunk? >>> >>> Isn't there an optab for sincos? >> >> This is exactly what I was going to suggest. This transformation >> should be done in the back-end back to sin/cos instructions. > > I didn't realize that the 387 has sin, cos and sincos instructions, > so yeah, my original patch is bad. > > Nathan, is this patch ok for trunk and gcc-6? It adds a new sincos > pattern in the nvptx backend. I haven't testing a standalone nvptx > toolchain prior to this patch, so I'm not sure if my test results > look sane. I seem to be getting a different set of failures when I > test a clean trunk build multiple times. I attached my results > below for reference. UNSPEC_SINCOS is unused so why add it? Thanks, Andrew Pinski > > Cesar > > g++.sum > Tests that now fail, but worked before: > > nvptx-none-run: g++.dg/abi/param1.C -std=c++14 execution test > > Tests that now work, but didn't before: > > nvptx-none-run: g++.dg/opt/pr30590.C -std=gnu++98 execution test > nvptx-none-run: g++.dg/opt/pr36187.C -std=gnu++14 execution test > > gfortran.sum > Tests that now fail, but worked before: > > nvptx-none-run: gfortran.dg/alloc_comp_assign_10.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > nvptx-none-run: gfortran.dg/allocate_with_source_5.f90 -O1 execution test > nvptx-none-run: gfortran.dg/func_assign_3.f90 -O3 -g execution test > nvptx-none-run: gfortran.dg/inline_sum_3.f90 -O1 execution test > nvptx-none-run: gfortran.dg/inline_sum_3.f90 -O3 -g execution test > nvptx-none-run: gfortran.dg/internal_pack_15.f90 -O2 execution test > nvptx-none-run: gfortran.dg/internal_pack_8.f90 -Os execution test > nvptx-none-run: gfortran.dg/intrinsic_ifunction_2.f90 -O0 execution test > nvptx-none-run: gfortran.dg/intrinsic_ifunction_2.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > nvptx-none-run: gfortran.dg/intrinsic_pack_5.f90 -O3 -g execution test > nvptx-none-run: gfortran.dg/intrinsic_product_1.f90 -O1 execution test > nvptx-none-run: gfortran.dg/intrinsic_verify_1.f90 -O3 -g execution test > nvptx-none-run: gfortran.dg/is_iostat_end_eor_1.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > nvptx-none-run: gfortran.dg/iso_c_binding_rename_1.f03 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > > Tests that now work, but didn't before: > > nvptx-none-run: gfortran.dg/char_pointer_assign.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > nvptx-none-run: gfortran.dg/char_pointer_dummy.f90 -O1 execution test > nvptx-none-run: gfortran.dg/char_pointer_dummy.f90 -Os execution test > nvptx-none-run: gfortran.dg/char_result_13.f90 -O3 -g execution test > nvptx-none-run: gfortran.dg/char_result_2.f90 -O1 execution test > nvptx-none-run: gfortran.dg/char_type_len.f90 -Os execution test > nvptx-none-run: gfortran.dg/character_array_constructor_1.f90 -O0 execution test > nvptx-none-run: gfortran.dg/nested_allocatables_1.f90 -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > > gcc.sum > Tests that now fail, but worked before: > > nvptx-none-run: gcc.c-torture/execute/20100316-1.c -Os execution test > nvptx-none-run: gcc.c-torture/execute/20100708-1.c -O1 execution test > nvptx-none-run: gcc.c-torture/execute/20100805-1.c -O0 execution test > nvptx-none-run: gcc.dg/torture/pr52028.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test > nvptx-none-run: gcc.dg/torture/pr52028.c -O3 -g execution test > > Tests that now work, but didn't before: > > nvptx-none-run: gcc.c-torture/execute/20091229-1.c -O3 -g execution test > nvptx-none-run: gcc.c-torture/execute/20101013-1.c -Os execution test > nvptx-none-run: gcc.c-torture/execute/20101025-1.c -Os execution test > nvptx-none-run: gcc.c-torture/execute/20120105-1.c -O0 execution test > nvptx-none-run: gcc.c-torture/execute/20120111-1.c -O0 execution test > > New tests that PASS: > > nvptx-none-run: gcc.target/nvptx/sincos-1.c (test for excess errors) > nvptx-none-run: gcc.target/nvptx/sincos-1.c scan-assembler-times cos.approx.f32 1 > nvptx-none-run: gcc.target/nvptx/sincos-1.c scan-assembler-times sin.approx.f32 1 > nvptx-none-run: gcc.target/nvptx/sincos-2.c (test for excess errors) > nvptx-none-run: gcc.target/nvptx/sincos-2.c execution test > > >>> ISTR x87 handles this pass just fine and also can do sin and cos. >>> >>> Richard. >>> >>>> Cesar >>> >>> >