From patchwork Fri May 4 12:30:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 8395 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 3473923EAB for ; Fri, 4 May 2012 12:30:39 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id E2A50A18ABA for ; Fri, 4 May 2012 12:30:38 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3361401yhp.11 for ; Fri, 04 May 2012 05:30:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:message-id :subject:to:date:from:cc:in-reply-to:x-mailer:mime-version :content-type:content-transfer-encoding:x-cbid:x-gm-message-state; bh=vIBNB2iEzY8hMfiTCdHn3Xl9Vr7N9iDML8aAlEYdqIY=; b=mWmpMQaMlor1PS/AlfDk7T3MESovd1zNQBEw/FLL6v3SwPduruVzAUFFxL1cRAlgNG wgpMFU5h9LJ7jr2nZp6rfLpwAZLq3mPMMN3geqOn5IOajnGCaz7WEVXeGcJ2dv7GqMXj yOGV+WE3VM9zGILBrhq2Sx73WlofVa6E7aqz/Ia89kJQ6chRzFDqbfaQsE/AfO9ZnGJP glFiOJoixqMQo98WeW+6/0sdhEAsLJgi/3TDoIu86XvWtO600vLMEcvxR2YLVOo/7j0L OTMmRjLMGWA8mzfgVrnUetT1NOT34KAiR3wC/qgkP2dsXXyhVGFf12Cg2izADW7H4Evk KnRg== Received: by 10.50.47.131 with SMTP id d3mr2869028ign.33.1336134638298; Fri, 04 May 2012 05:30:38 -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.231.137.198 with SMTP id x6csp86530ibt; Fri, 4 May 2012 05:30:37 -0700 (PDT) Received: by 10.180.88.169 with SMTP id bh9mr8900850wib.5.1336134636963; Fri, 04 May 2012 05:30:36 -0700 (PDT) Received: from e06smtp17.uk.ibm.com (e06smtp17.uk.ibm.com. [195.75.94.113]) by mx.google.com with ESMTPS id n52si9649008wed.91.2012.05.04.05.30.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 05:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of uweigand@de.ibm.com designates 195.75.94.113 as permitted sender) client-ip=195.75.94.113; Authentication-Results: mx.google.com; spf=pass (google.com: domain of uweigand@de.ibm.com designates 195.75.94.113 as permitted sender) smtp.mail=uweigand@de.ibm.com Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 May 2012 13:30:36 +0100 Received: from d06nrmr1707.portsmouth.uk.ibm.com (9.149.39.225) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 4 May 2012 13:30:33 +0100 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q44CUWqo2301990 for ; Fri, 4 May 2012 13:30:32 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q44CUWec005994 for ; Fri, 4 May 2012 06:30:32 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id q44CUU6x005935; Fri, 4 May 2012 06:30:30 -0600 Message-Id: <201205041230.q44CUU6x005935@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 04 May 2012 14:30:30 +0200 Subject: Re: [PATCH 2/2] Minor refactoring of tree-vect-patterns.c To: richard.guenther@gmail.com (Richard Guenther) Date: Fri, 4 May 2012 14:30:30 +0200 (CEST) From: "Ulrich Weigand" Cc: gcc-patches@gcc.gnu.org, patches@linaro.org In-Reply-To: from "Richard Guenther" at May 02, 2012 11:35:42 AM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 x-cbid: 12050412-0542-0000-0000-000001C4B3F8 X-Gm-Message-State: ALoCoQkzZoUp9hli2L3DYGnyV6SnMifVl2MnImplZfrbXrYaih4u/xzTgwIJxYG8xDw4UcIofWlt Richard Guenther wrote: > On Mon, Apr 30, 2012 at 6:19 PM, Ulrich Weigand wrote: > > Hello, > > > > as a second step in refactoring this patch introduces a routine > > vect_find_single_use to determine whether a defining statement > > has one single use within the current vectorization domain. > > > > The helper is then called wherever that check is currently > > open-coded. =A0There should be no change in behaviour. > > > > Tested on i386-linux-gnu and arm-linux-gnueabi with no regressions. > > > > OK for mainline? > > You can use single_imm_use to avoid the loop and simplify the factored > routine. > > Ok with that change. I've checked in the version appended below. Thanks, Ulrich ChangeLog: * tree-vect-patterns.c (vect_single_imm_use): New function. (vect_recog_widen_mult_pattern): Use it instead of open-coding loop. (vect_recog_over_widening_pattern): Likewise. (vect_recog_widen_shift_pattern): Likewise. Index: gcc-head/gcc/tree-vect-patterns.c =================================================================== --- gcc-head.orig/gcc/tree-vect-patterns.c 2012-05-04 14:23:18.000000000 +0200 +++ gcc-head/gcc/tree-vect-patterns.c 2012-05-04 14:23:38.000000000 +0200 @@ -119,6 +119,25 @@ vect_same_loop_or_bb_p (gimple stmt1, gi return true; } +/* If the LHS of DEF_STMT has a single use, and that statement is + in the same loop or basic block, return it. */ + +static gimple +vect_single_imm_use (gimple def_stmt) +{ + tree lhs = gimple_assign_lhs (def_stmt); + use_operand_p use_p; + gimple use_stmt; + + if (!single_imm_use (lhs, &use_p, &use_stmt)) + return NULL; + + if (!vect_same_loop_or_bb_p (def_stmt, use_stmt)) + return NULL; + + return use_stmt; +} + /* Check whether NAME, an ssa-name used in USE_STMT, is a result of a type promotion or demotion, such that: DEF_STMT: NAME = NOP (name0) @@ -636,31 +655,18 @@ vect_recog_widen_mult_pattern (VEC (gimp Use unsigned TYPE as the type for WIDEN_MULT_EXPR. */ if (TYPE_UNSIGNED (type) != TYPE_UNSIGNED (half_type0)) { - tree lhs = gimple_assign_lhs (last_stmt), use_lhs; - imm_use_iterator imm_iter; - use_operand_p use_p; - int nuses = 0; - gimple use_stmt = NULL; + gimple use_stmt; + tree use_lhs; tree use_type; if (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (half_type1)) return NULL; - FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) - { - if (is_gimple_debug (USE_STMT (use_p))) - continue; - use_stmt = USE_STMT (use_p); - nuses++; - } - - if (nuses != 1 || !is_gimple_assign (use_stmt) - || gimple_assign_rhs_code (use_stmt) != NOP_EXPR) + use_stmt = vect_single_imm_use (last_stmt); + if (!use_stmt || !is_gimple_assign (use_stmt) + || gimple_assign_rhs_code (use_stmt) != NOP_EXPR) return NULL; - if (!vect_same_loop_or_bb_p (last_stmt, use_stmt)) - return NULL; - use_lhs = gimple_assign_lhs (use_stmt); use_type = TREE_TYPE (use_lhs); if (!INTEGRAL_TYPE_P (use_type) @@ -1165,10 +1171,7 @@ vect_recog_over_widening_pattern (VEC (g { gimple stmt = VEC_pop (gimple, *stmts); gimple pattern_stmt = NULL, new_def_stmt, prev_stmt = NULL, use_stmt = NULL; - tree op0, op1, vectype = NULL_TREE, lhs, use_lhs, use_type; - imm_use_iterator imm_iter; - use_operand_p use_p; - int nuses = 0; + tree op0, op1, vectype = NULL_TREE, use_lhs, use_type; tree var = NULL_TREE, new_type = NULL_TREE, tmp, new_oprnd; bool first; tree type = NULL; @@ -1192,18 +1195,8 @@ vect_recog_over_widening_pattern (VEC (g } /* STMT can be performed on a smaller type. Check its uses. */ - lhs = gimple_assign_lhs (stmt); - nuses = 0; - FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) - { - if (is_gimple_debug (USE_STMT (use_p))) - continue; - use_stmt = USE_STMT (use_p); - nuses++; - } - - if (nuses != 1 || !is_gimple_assign (use_stmt) - || !vect_same_loop_or_bb_p (stmt, use_stmt)) + use_stmt = vect_single_imm_use (stmt); + if (!use_stmt || !is_gimple_assign (use_stmt)) return NULL; /* Create pattern statement for STMT. */ @@ -1454,12 +1447,6 @@ vect_recog_widen_shift_pattern (VEC (gim Use unsigned TYPE as the type for WIDEN_LSHIFT_EXPR. */ if (TYPE_UNSIGNED (type) != TYPE_UNSIGNED (half_type0)) { - tree lhs = gimple_assign_lhs (last_stmt), use_lhs; - imm_use_iterator imm_iter; - use_operand_p use_p; - int nuses = 0; - tree use_type; - if (over_widen) { /* In case of over-widening pattern, S4 should be ORIG_STMT itself. @@ -1472,21 +1459,14 @@ vect_recog_widen_shift_pattern (VEC (gim } else { - FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) - { - if (is_gimple_debug (USE_STMT (use_p))) - continue; - use_stmt = USE_STMT (use_p); - nuses++; - } + tree use_type; + tree use_lhs; - if (nuses != 1 || !is_gimple_assign (use_stmt) + use_stmt = vect_single_imm_use (last_stmt); + if (!use_stmt || !is_gimple_assign (use_stmt) || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (use_stmt))) return NULL; - if (!vect_same_loop_or_bb_p (last_stmt, use_stmt)) - return NULL; - use_lhs = gimple_assign_lhs (use_stmt); use_type = TREE_TYPE (use_lhs);