From patchwork Tue Apr 9 16:24:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joern Rennecke X-Patchwork-Id: 235140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DCEC22C00AD for ; Wed, 10 Apr 2013 02:24:42 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:to:cc:subject:references:in-reply-to :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=WJ3dz874Tsnw7UQEzT6Ovix2bICnWqbxKoZXgsEPYvFssESAoiNFn v90VPFrz6aeACv+SncakyHQmX6Sv3O+gdAzMnpQHHoii4/AzaThsQ/Aio5+tEvwZ r1gOvTglNxE5ruXjjbr9upkipjoKteNyz4WnRDwwPtiZjH2GwK4P6M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:to:cc:subject:references:in-reply-to :mime-version:content-type:content-transfer-encoding; s=default; bh=ioHL7biokT3j88hTVhnHRi5wOfY=; b=fHMEvSGmKwyFjSh14CCdtpuQmQoK eVVtPZ4brkQiesAbtznYEQgD5V7JmuXOQGpK4P6a3PojGfpN8BixRhdBoX8yu2u6 7pfC9+JPVY+YMY/XtxMnPfnq5NnzzmhHCZZANV20o62UzmbT+izG46Qd4vxq412b +Vy1iREcPFhOPY4= Received: (qmail 14960 invoked by alias); 9 Apr 2013 16:24:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk 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 14950 invoked by uid 89); 9 Apr 2013 16:24:36 -0000 X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, MIME_QP_LONG_LINE, TW_TM autolearn=ham version=3.3.1 Received: from c62.cesmail.net (HELO c62.cesmail.net) (216.154.195.54) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 09 Apr 2013 16:24:35 +0000 Received: from unknown (HELO epsilon2) ([192.168.1.60]) by c62.cesmail.net with ESMTP; 09 Apr 2013 12:24:34 -0400 Received: from cust213-dsl91-135-11.idnet.net (cust213-dsl91-135-11.idnet.net [91.135.11.213]) by webmail.spamcop.net (Horde MIME library) with HTTP; Tue, 09 Apr 2013 12:24:33 -0400 Message-ID: <20130409122433.lbfstq22o0g4g4ko-nzlynne@webmail.spamcop.net> Date: Tue, 09 Apr 2013 12:24:33 -0400 From: Joern Rennecke To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: RFA: Fix tree-optimization/55524 References: <20130408111056.gvvtnyc8w04cww8g-nzlynne@webmail.spamcop.net> <20130409105304.awkedy7bzwc8ww8o-nzlynne@webmail.spamcop.net> In-Reply-To: MIME-Version: 1.0 User-Agent: Internet Messaging Program (IMP) H3 (4.1.4) X-Virus-Found: No Quoting Richard Biener : > I don't see that. It's merely a complication of optimal handling of > a * b +- c * d vs. just a * b +- c. The pass does simple pattern matching > only, not doing a global optimal transform, so adding another special-case > is reasonable. Special-casing just for single-use 2nd multiplication > simplifies the cases for example. I have attached a version of the patch that uses this simpler test. Currently bootstrapping / regtesting on i686-pc-linux-gnu . gcc: 2013-04-09 Joern Rennecke PR tree-optimization/55524 * tree-ssa-math-opts.c (convert_mult_to_fma): Don't use an fms construct when we don't have an fms operation, but fnma, and it looks likely that we'll be able to use the latter. gcc/testsuite: 2013-04-09 Joern Rennecke PR tree-optimization/55524 * gcc.target/epiphany/fnma-1.c: New test. Index: testsuite/gcc.target/epiphany/fnma-1.c =================================================================== --- testsuite/gcc.target/epiphany/fnma-1.c (revision 0) +++ testsuite/gcc.target/epiphany/fnma-1.c (working copy) @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-times "fmsub\[ \ta-zA-Z0-9\]*," 1 } } */ + +float +f (float ar, float ai, float br, float bi) +{ + return ar * br - ai * bi; +} Index: tree-ssa-math-opts.c =================================================================== --- tree-ssa-math-opts.c (revision 197578) +++ tree-ssa-math-opts.c (working copy) @@ -2570,6 +2570,24 @@ convert_mult_to_fma (gimple mul_stmt, tr return false; } + /* If the subtrahend (gimple_assign_rhs2 (use_stmt)) is computed + by a MULT_EXPR that we'll visit later, we might be able to + get a more profitable match with fnma. + OTOH, if we don't, a negate / fma pair has likely lower latency + that a mult / subtract pair. */ + if (use_code == MINUS_EXPR && !negate_p + && gimple_assign_rhs1 (use_stmt) == result + && optab_handler (fms_optab, TYPE_MODE (type)) == CODE_FOR_nothing + && optab_handler (fnma_optab, TYPE_MODE (type)) != CODE_FOR_nothing) + { + tree rhs2 = gimple_assign_rhs2 (use_stmt); + gimple stmt2 = SSA_NAME_DEF_STMT (rhs2); + + if (has_single_use (rhs2) + && gimple_assign_rhs_code (stmt2) == MULT_EXPR) + return false; + } + /* We can't handle a * b + a * b. */ if (gimple_assign_rhs1 (use_stmt) == gimple_assign_rhs2 (use_stmt)) return false;