From patchwork Thu Jul 14 14:28:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 2695 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 F1DB724259 for ; Thu, 14 Jul 2011 14:28:08 +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 BA129A18105 for ; Thu, 14 Jul 2011 14:28:08 +0000 (UTC) Received: by qyk30 with SMTP id 30so255322qyk.11 for ; Thu, 14 Jul 2011 07:28:08 -0700 (PDT) Received: by 10.229.217.3 with SMTP id hk3mr1944523qcb.38.1310653688148; Thu, 14 Jul 2011 07:28:08 -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.217.78 with SMTP id hl14cs17022qcb; Thu, 14 Jul 2011 07:28:07 -0700 (PDT) Received: by 10.42.243.65 with SMTP id ll1mr2318572icb.405.1310653686962; Thu, 14 Jul 2011 07:28:06 -0700 (PDT) Received: from mail.codesourcery.com (mail.codesourcery.com [38.113.113.100]) by mx.google.com with ESMTPS id r20si411392ibk.43.2011.07.14.07.28.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jul 2011 07:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ams@codesourcery.com designates 38.113.113.100 as permitted sender) client-ip=38.113.113.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ams@codesourcery.com designates 38.113.113.100 as permitted sender) smtp.mail=ams@codesourcery.com Received: (qmail 9207 invoked from network); 14 Jul 2011 14:28:05 -0000 Received: from unknown (HELO ?192.168.0.100?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 14 Jul 2011 14:28:05 -0000 Message-ID: <4E1EFCF3.9040809@codesourcery.com> Date: Thu, 14 Jul 2011 15:28:03 +0100 From: Andrew Stubbs Organization: CodeSourcery User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110627 Thunderbird/5.0 MIME-Version: 1.0 To: Richard Guenther CC: gcc-patches@gcc.gnu.org, patches@linaro.org Subject: Re: [PATCH (5/7)] Widening multiplies for mis-matched mode inputs References: <4E034EF2.3070503@codesourcery.com> <4E0350B7.7080802@codesourcery.com> <4E09EE62.9070900@codesourcery.com> <4E11CE4F.1020102@codesourcery.com> In-Reply-To: I've updated this patch following the changes earlier in the patch series. There isn't much left. This should obviate all the review comments. :) OK? Andrew 2011-07-14 Andrew Stubbs gcc/ * tree-ssa-math-opts.c (is_widening_mult_p): Remove FIXME. Ensure the the larger type is the first operand. gcc/testsuite/ * gcc.target/arm/wmul-7.c: New file. --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/wmul-7.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=armv7-a" } */ + +unsigned long long +foo (unsigned long long a, unsigned char *b, unsigned short *c) +{ + return a + *b * *c; +} + +/* { dg-final { scan-assembler "umlal" } } */ --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2053,9 +2053,17 @@ is_widening_mult_p (gimple stmt, *type2_out = *type1_out; } - /* FIXME: remove this restriction. */ - if (TYPE_PRECISION (*type1_out) != TYPE_PRECISION (*type2_out)) - return false; + /* Ensure that the larger of the two operands comes first. */ + if (TYPE_PRECISION (*type1_out) < TYPE_PRECISION (*type2_out)) + { + tree tmp; + tmp = *type1_out; + *type1_out = *type2_out; + *type2_out = tmp; + tmp = *rhs1_out; + *rhs1_out = *rhs2_out; + *rhs2_out = tmp; + } return true; }