From patchwork Thu Jun 23 14:40:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 2226 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F230A23F7C for ; Thu, 23 Jun 2011 14:40:17 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id C379EA189B8 for ; Thu, 23 Jun 2011 14:40:17 +0000 (UTC) Received: by qyk30 with SMTP id 30so1384965qyk.11 for ; Thu, 23 Jun 2011 07:40:17 -0700 (PDT) Received: by 10.229.30.3 with SMTP id s3mr464416qcc.21.1308840017263; Thu, 23 Jun 2011 07:40:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.230.139 with SMTP id jm11cs19863qcb; Thu, 23 Jun 2011 07:40:17 -0700 (PDT) Received: by 10.227.152.16 with SMTP id e16mr763794wbw.112.1308840016316; Thu, 23 Jun 2011 07:40:16 -0700 (PDT) Received: from mail-ww0-f42.google.com (mail-ww0-f42.google.com [74.125.82.42]) by mx.google.com with ESMTPS id e5si3956396wbh.113.2011.06.23.07.40.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Jun 2011 07:40:15 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of andrew.stubbs@linaro.org) client-ip=74.125.82.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of andrew.stubbs@linaro.org) smtp.mail=andrew.stubbs@linaro.org Received: by wwg11 with SMTP id 11so2211721wwg.1 for ; Thu, 23 Jun 2011 07:40:14 -0700 (PDT) Received: by 10.227.201.144 with SMTP id fa16mr2057690wbb.19.1308840014769; Thu, 23 Jun 2011 07:40:14 -0700 (PDT) Received: from [192.168.0.100] (cpc2-hawk4-0-0-cust828.aztw.cable.virginmedia.com [82.32.123.61]) by mx.google.com with ESMTPS id en1sm1282916wbb.35.2011.06.23.07.40.13 (version=SSLv3 cipher=OTHER); Thu, 23 Jun 2011 07:40:13 -0700 (PDT) Message-ID: <4E03504B.9060305@codesourcery.com> Date: Thu, 23 Jun 2011 15:40:11 +0100 From: Andrew Stubbs User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: patches@linaro.org Subject: [PATCH (3/7)] Widening multiply-and-accumulate pattern matching References: <4E034EF2.3070503@codesourcery.com> In-Reply-To: <4E034EF2.3070503@codesourcery.com> There are many cases where the widening_mult pass does not recognise widening multiply-and-accumulate cases simply because there is a type conversion step between the multiply and add statements. This patch should rectify that simply by looking beyond those conversions. OK? Andrew 2011-06-23 Andrew Stubbs gcc/ * tree-ssa-math-opts.c (convert_plusminus_to_widen): Look for multiply statement beyond NOP_EXPR statements. gcc/testsuite/ * gcc.target/arm/umlal-1.c: New file. --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/umlal-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=armv7-a" } */ + +long long +foo (long long a, char *b, char *c) +{ + return a + *b * *c; +} + +/* { dg-final { scan-assembler "umlal" } } */ --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2114,26 +2114,39 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple stmt, else wmult_code = WIDEN_MULT_PLUS_EXPR; - rhs1 = gimple_assign_rhs1 (stmt); - rhs2 = gimple_assign_rhs2 (stmt); - - if (TREE_CODE (rhs1) == SSA_NAME) + rhs1_stmt = stmt; + do { - rhs1_stmt = SSA_NAME_DEF_STMT (rhs1); - if (is_gimple_assign (rhs1_stmt)) - rhs1_code = gimple_assign_rhs_code (rhs1_stmt); + rhs1_code = ERROR_MARK; + rhs1 = gimple_assign_rhs1 (rhs1_stmt); + + if (TREE_CODE (rhs1) == SSA_NAME) + { + rhs1_stmt = SSA_NAME_DEF_STMT (rhs1); + if (is_gimple_assign (rhs1_stmt)) + rhs1_code = gimple_assign_rhs_code (rhs1_stmt); + } + else + return false; } - else - return false; + while (rhs1_code == NOP_EXPR); - if (TREE_CODE (rhs2) == SSA_NAME) + rhs2_stmt = stmt; + do { - rhs2_stmt = SSA_NAME_DEF_STMT (rhs2); - if (is_gimple_assign (rhs2_stmt)) - rhs2_code = gimple_assign_rhs_code (rhs2_stmt); + rhs2_code = ERROR_MARK; + rhs2 = gimple_assign_rhs2 (rhs2_stmt); + + if (rhs2 && TREE_CODE (rhs2) == SSA_NAME) + { + rhs2_stmt = SSA_NAME_DEF_STMT (rhs2); + if (is_gimple_assign (rhs2_stmt)) + rhs2_code = gimple_assign_rhs_code (rhs2_stmt); + } + else + return false; } - else - return false; + while (rhs2_code == NOP_EXPR); if (code == PLUS_EXPR && rhs1_code == MULT_EXPR) {