From patchwork Mon Jul 18 13:14:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 105272 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]) by ozlabs.org (Postfix) with SMTP id 02BA9B6FF5 for ; Mon, 18 Jul 2011 23:14:49 +1000 (EST) Received: (qmail 32157 invoked by alias); 18 Jul 2011 13:14:45 -0000 Received: (qmail 32146 invoked by uid 22791); 18 Jul 2011 13:14:44 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_TM X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Jul 2011 13:14:10 +0000 Received: (qmail 27936 invoked from network); 18 Jul 2011 13:14:09 -0000 Received: from unknown (HELO ?192.168.0.100?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Jul 2011 13:14:09 -0000 Message-ID: <4E24319D.3040607@codesourcery.com> Date: Mon, 18 Jul 2011 14:14:05 +0100 From: Andrew Stubbs User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110627 Thunderbird/5.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH (8/7)] Fix a bug in multiply-and-accumulate References: <4E034EF2.3070503@codesourcery.com> In-Reply-To: <4E034EF2.3070503@codesourcery.com> 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 As far as I can tell, the patch series so far works great as long as the input type of the accumulate value is the same as the output type. Unfortunately you get an ICE otherwise .... doh! This patch should fix the problem. I could have inserted this fix into the correct spot in the existing series, but I've already regenerated the whole lot several times, it's getting confusing, and they're all approved already, so I'm just going to tack this one on the end. Andrew 2011-07-18 Andrew Stubbs gcc/ * tree-ssa-math-opts.c (convert_plusminus_to_widen): Convert add_rhs to the correct type. gcc/testsuite/ * gcc.target/arm/wmul-10.c: New file. --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/wmul-10.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=armv7-a" } */ + +unsigned long long +foo (unsigned short a, unsigned short *b, unsigned short *c) +{ + return (unsigned)a + (unsigned long long)*b * (unsigned long long)*c; +} + +/* { dg-final { scan-assembler "umlal" } } */ --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2375,6 +2375,10 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple stmt, mult_rhs2 = build_and_insert_cast (gsi, loc, tmp, mult_rhs2); } + if (TYPE_PRECISION (type) != TYPE_PRECISION (TREE_TYPE (add_rhs))) + add_rhs = build_and_insert_cast (gsi, loc, create_tmp_var (type, NULL), + add_rhs); + gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, mult_rhs1, mult_rhs2, add_rhs); update_stmt (gsi_stmt (*gsi));