From patchwork Tue Oct 20 16:14:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 55314 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id D381923024 for ; Tue, 20 Oct 2015 16:15:13 +0000 (UTC) Received: by lffv3 with SMTP id v3sf7258059lff.1 for ; Tue, 20 Oct 2015 09:15:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=PLbB6+OiRQlcXkuWYeWXTT6JyWVlelBPmWDJ/wh0FHc=; b=UTma3EdCJl1fexmU11KcqaXYe2yNAitUDg9S4NOMbl+UNLMGMghzR98uTUnQfjkFLq 7IY8suosOcES1fwGdm+NZzSszOZ3qmzeIYwqiNRG6Ms6nHf5cmWTY7DDaKjJ6HCQeYNi hqeXyHpX1sj2eLO4PdSLeNeAu3br+gE0doxfvAUCiLb4qHcPN9gSLa0PXGEeo6nQtffE Tbpa+5OdrL3vt0Uyjj9S1GF0w/4WF1Xqq4wEhZa462YUC/nzSCbeoXIylVKyous04V/N bfOLsqmPu92tICqO4CqQ/uiYdLU2yRy8h5xkeuNJx98l6yHP4K1S9XdyAz4GHR0wfjOW Q20A== X-Gm-Message-State: ALoCoQkMZ+7Im9A1gesM3WEZEuhU+JzmHR2shy8ICvGFg8q8/XbLJIoSeUdMN+QBYLiwdJvJX3Lb X-Received: by 10.112.12.132 with SMTP id y4mr845790lbb.0.1445357712827; Tue, 20 Oct 2015 09:15:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.143.76 with SMTP id r73ls110996lfd.6.gmail; Tue, 20 Oct 2015 09:15:12 -0700 (PDT) X-Received: by 10.25.152.204 with SMTP id a195mr1581004lfe.66.1445357712679; Tue, 20 Oct 2015 09:15:12 -0700 (PDT) Received: from mail-lb0-x230.google.com (mail-lb0-x230.google.com. [2a00:1450:4010:c04::230]) by mx.google.com with ESMTPS id mj2si2849743lbc.55.2015.10.20.09.15.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 09:15:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) client-ip=2a00:1450:4010:c04::230; Received: by lbbes7 with SMTP id es7so19131128lbb.2 for ; Tue, 20 Oct 2015 09:15:12 -0700 (PDT) X-Received: by 10.112.163.131 with SMTP id yi3mr2406759lbb.36.1445357712351; Tue, 20 Oct 2015 09:15:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2176264lbq; Tue, 20 Oct 2015 09:15:11 -0700 (PDT) X-Received: by 10.68.239.165 with SMTP id vt5mr4819976pbc.15.1445357710985; Tue, 20 Oct 2015 09:15:10 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id qx6si6144022pab.180.2015.10.20.09.15.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 09:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-410688-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 108949 invoked by alias); 20 Oct 2015 16:14:55 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 108936 invoked by uid 89); 20 Oct 2015 16:14:54 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Oct 2015 16:14:53 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-9-RsYt2MnZSk-mneotfJIHQQ-1; Tue, 20 Oct 2015 17:14:47 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 20 Oct 2015 17:14:46 +0100 Message-ID: <56266876.4030806@arm.com> Date: Tue, 20 Oct 2015 17:14:46 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Bernd Schmidt , GCC Patches CC: Eric Botcazou , Segher Boessenkool Subject: Re: [PATCH][simplify-rtx][2/2] Use constants from pool when simplifying binops References: <5624F6E2.6090501@arm.com> <5624FECB.5030105@redhat.com> <56250034.3030406@arm.com> In-Reply-To: <56250034.3030406@arm.com> X-MC-Unique: RsYt2MnZSk-mneotfJIHQQ-1 X-IsSubscribed: yes X-Original-Sender: kyrylo.tkachov@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::230 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 On 19/10/15 15:37, Kyrill Tkachov wrote: > Hi Bernd, > > On 19/10/15 15:31, Bernd Schmidt wrote: >> On 10/19/2015 03:57 PM, Kyrill Tkachov wrote: >>> This second patch teaches simplify_binary_operation to return the >>> dereferenced >>> constants from the constant pool in the binary expression if other >>> simplifications failed. >>> >>> This, combined with the 1/2 patch for aarch64 >>> (https://gcc.gnu.org/ml/gcc-patches/2015-10/msg01744.html) allow for: >>> >>> int >>> foo (float a) >>> { >>> return a * 32.0f; >>> } >>> >>> to generate the code: >>> foo: >>> fcvtzs w0, s0, #5 >>> ret >>> >>> because combine now successfully tries to match: >>> (set (reg/i:SI 0 x0) >>> (fix:SI (mult:SF (reg:SF 32 v0 [ a ]) >>> (const_double:SF 3.2e+1 [0x0.8p+6])))) >>> >>> whereas before it would not try the to use the const_double directly >>> but rather its constant pool reference. >> >> The only way I could see a problem with that if there are circumstances where the memory variant would simplify further. That doesn't seem highly likely, so... >> > > I that were the case, I'd expect the earlier call to simplify_binary_operation_1 have returned a non-NULL rtx, > and the code in this patch would not come into play. > >>> * simplify-rtx.c (simplify_binary_operation): If either operand was >>> a constant pool reference use them if all other simplifications >>> failed. >> >> Ok. > > Thanks, > I'll commit it when the first (aarch64-specific) patch is approved. > This patch has already been ok'd, but I'd like to update the aarch64 test to use scan-assembler-times rather that just scan-assembler in light of Marcus' feedback to another patch. I committed this version to trunk with r229086. Thanks, Kyrill 2015-10-20 Kyrylo Tkachov * simplify-rtx.c (simplify_binary_operation): If either operand was a constant pool reference use them if all other simplifications failed. 2015-10-20 Kyrylo Tkachov * gcc.target/aarch64/fmul_fcvt_1.c: Add multiply-by-32 cases. > Kyrill > >> >> >> Bernd >> > Index: gcc/testsuite/gcc.target/aarch64/fmul_fcvt_1.c =================================================================== --- gcc/testsuite/gcc.target/aarch64/fmul_fcvt_1.c (revision 229085) +++ gcc/testsuite/gcc.target/aarch64/fmul_fcvt_1.c (working copy) @@ -83,6 +83,16 @@ /* { dg-final { scan-assembler-times "fcvtzu\tx\[0-9\], d\[0-9\]*.*#4" 1 } } */ /* { dg-final { scan-assembler-times "fcvtzu\tw\[0-9\], d\[0-9\]*.*#4" 1 } } */ +FUNC_DEFS (32) +FUNC_DEFD (32) +/* { dg-final { scan-assembler-times "fcvtzs\tw\[0-9\], s\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzs\tx\[0-9\], s\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzs\tx\[0-9\], d\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzs\tw\[0-9\], d\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzu\tw\[0-9\], s\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzu\tx\[0-9\], s\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzu\tx\[0-9\], d\[0-9\]*.*#5" 1 } } */ +/* { dg-final { scan-assembler-times "fcvtzu\tw\[0-9\], d\[0-9\]*.*#5" 1 } } */ #define FUNC_TESTS(__a, __b) \ do \ @@ -120,10 +130,12 @@ FUNC_TESTS (4, i); FUNC_TESTS (8, i); FUNC_TESTS (16, i); + FUNC_TESTS (32, i); FUNC_TESTD (4, i); FUNC_TESTD (8, i); FUNC_TESTD (16, i); + FUNC_TESTD (32, i); } return 0; } Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c (revision 229084) +++ gcc/simplify-rtx.c (working copy) @@ -2001,7 +2001,17 @@ tem = simplify_const_binary_operation (code, mode, trueop0, trueop1); if (tem) return tem; - return simplify_binary_operation_1 (code, mode, op0, op1, trueop0, trueop1); + tem = simplify_binary_operation_1 (code, mode, op0, op1, trueop0, trueop1); + + if (tem) + return tem; + + /* If the above steps did not result in a simplification and op0 or op1 + were constant pool references, use the referenced constants directly. */ + if (trueop0 != op0 || trueop1 != op1) + return simplify_gen_binary (code, mode, trueop0, trueop1); + + return NULL_RTX; } /* Subroutine of simplify_binary_operation. Simplify a binary operation