From patchwork Fri May 4 12:29:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 8394 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 1FFEC23EAB for ; Fri, 4 May 2012 12:29:42 +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 C2698A18AB7 for ; Fri, 4 May 2012 12:29:41 +0000 (UTC) Received: by yhpp61 with SMTP id p61so3360310yhp.11 for ; Fri, 04 May 2012 05:29:41 -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:x-mailer:mime-version:content-type :content-transfer-encoding:x-cbid:x-gm-message-state; bh=n+Cvj39CEX6AsqPB3KaYqAdpySYFulOE7IvM+StL4Fk=; b=KPdcVHlay5tN1XZ++lQAkuOk2teEOoTjsOFnfZQpWZvP/ibmqM1uXiTYWoVrDDKErZ 1b7moh+ZGKboywtYHydb9HSuDA9Q8teFmCVT06Fvm4i2cno+3dHJ7UXbHUlNKHOUqR/5 6P/KXVR+Tyoo2jbVICY9LHfPsSp24VgRfN0KwEg3wYQ6RKg3ym5f3NyI1w9w9KIOUpsY sVDiOTPk3bkQp11g7SZEjsL4qF5nLEeW82WSXk1jLDYA+ONSU2f7OLSJrdITld9I9dUZ YzpBwtzLH4bCfDUPB43igjccTaZAS5Jbr50SM6zS4N8ciIN9mQchPqcO8rxWZfiM3vI0 LCtQ== Received: by 10.50.41.196 with SMTP id h4mr2863815igl.33.1336134581042; Fri, 04 May 2012 05:29:41 -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 x6csp86465ibt; Fri, 4 May 2012 05:29:39 -0700 (PDT) Received: by 10.180.102.100 with SMTP id fn4mr12644714wib.1.1336134579101; Fri, 04 May 2012 05:29:39 -0700 (PDT) Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com. [195.75.94.111]) by mx.google.com with ESMTPS id cf6si5630664wib.47.2012.05.04.05.29.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 May 2012 05:29:39 -0700 (PDT) Received-SPF: pass (google.com: domain of uweigand@de.ibm.com designates 195.75.94.111 as permitted sender) client-ip=195.75.94.111; Authentication-Results: mx.google.com; spf=pass (google.com: domain of uweigand@de.ibm.com designates 195.75.94.111 as permitted sender) smtp.mail=uweigand@de.ibm.com Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 4 May 2012 13:29:37 +0100 Received: from d06nrmr1707.portsmouth.uk.ibm.com (9.149.39.225) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 4 May 2012 13:29:28 +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 q44CTRWe2666658 for ; Fri, 4 May 2012 13:29:27 +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 q44CTRoZ003532 for ; Fri, 4 May 2012 06:29:27 -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 q44CTQEA003511 for ; Fri, 4 May 2012 06:29:26 -0600 Message-Id: <201205041229.q44CTQEA003511@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 04 May 2012 14:29:26 +0200 Subject: [PATCH 1/2] Minor refactoring of tree-vect-patterns.c To: patches@linaro.org Date: Fri, 4 May 2012 14:29:26 +0200 (CEST) From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 x-cbid: 12050412-0342-0000-0000-0000019AA5F1 X-Gm-Message-State: ALoCoQlNGqtczwAaYqHKwFcTj4tc4/BFUZ+GRZwq4UbPDL0IzRQFCorI+OOoehQIyG5tp+AUBWMG http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01891.html ChangeLog: * tree-vect-patterns.c (vect_same_loop_or_bb_p): New function. (vect_handle_widen_op_by_const): Use it instead of open-coding test. (vect_recog_widen_mult_pattern): Likewise. (vect_operation_fits_smaller_type): Likewise. (vect_recog_over_widening_pattern): Likewise. (vect_recog_widen_shift_pattern): Add to vect_same_loop_or_bb_p test. Index: gcc-head/gcc/tree-vect-patterns.c =================================================================== --- gcc-head.orig/gcc/tree-vect-patterns.c 2012-04-26 15:53:48.000000000 +0200 +++ gcc-head/gcc/tree-vect-patterns.c 2012-04-26 19:46:12.000000000 +0200 @@ -84,6 +84,41 @@ new_pattern_def_seq (stmt_vec_info stmt_ append_pattern_def_seq (stmt_info, stmt); } +/* Check whether STMT2 is in the same loop or basic block as STMT1. + Which of the two applies depends on whether we're currently doing + loop-based or basic-block-based vectorization, as determined by + the vinfo_for_stmt for STMT1 (which must be defined). + + If this returns true, vinfo_for_stmt for STMT2 is guaranteed + to be defined as well. */ + +static bool +vect_same_loop_or_bb_p (gimple stmt1, gimple stmt2) +{ + stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt1); + loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); + bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo); + + if (!gimple_bb (stmt2)) + return false; + + if (loop_vinfo) + { + struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); + if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt2))) + return false; + } + else + { + if (gimple_bb (stmt2) != BB_VINFO_BB (bb_vinfo) + || gimple_code (stmt2) == GIMPLE_PHI) + return false; + } + + gcc_assert (vinfo_for_stmt (stmt2)); + return true; +} + /* 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) @@ -400,16 +435,6 @@ vect_handle_widen_op_by_const (gimple st { tree new_type, new_oprnd, tmp; gimple new_stmt; - loop_vec_info loop_vinfo; - struct loop *loop = NULL; - bb_vec_info bb_vinfo; - stmt_vec_info stmt_vinfo; - - stmt_vinfo = vinfo_for_stmt (stmt); - loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); - bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo); - if (loop_vinfo) - loop = LOOP_VINFO_LOOP (loop_vinfo); if (code != MULT_EXPR && code != LSHIFT_EXPR) return false; @@ -425,12 +450,10 @@ vect_handle_widen_op_by_const (gimple st return true; } - if (TYPE_PRECISION (type) < (TYPE_PRECISION (*half_type) * 4) - || !gimple_bb (def_stmt) - || (loop && !flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))) - || (!loop && gimple_bb (def_stmt) != BB_VINFO_BB (bb_vinfo) - && gimple_code (def_stmt) != GIMPLE_PHI) - || !vinfo_for_stmt (def_stmt)) + if (TYPE_PRECISION (type) < (TYPE_PRECISION (*half_type) * 4)) + return false; + + if (!vect_same_loop_or_bb_p (stmt, def_stmt)) return false; /* TYPE is 4 times bigger than HALF_TYPE, try widening operation for @@ -564,16 +587,6 @@ vect_recog_widen_mult_pattern (VEC (gimp VEC (tree, heap) *dummy_vec; bool op1_ok; bool promotion; - loop_vec_info loop_vinfo; - struct loop *loop = NULL; - bb_vec_info bb_vinfo; - stmt_vec_info stmt_vinfo; - - stmt_vinfo = vinfo_for_stmt (last_stmt); - loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); - bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo); - if (loop_vinfo) - loop = LOOP_VINFO_LOOP (loop_vinfo); if (!is_gimple_assign (last_stmt)) return NULL; @@ -645,9 +658,7 @@ vect_recog_widen_mult_pattern (VEC (gimp || gimple_assign_rhs_code (use_stmt) != NOP_EXPR) return NULL; - if (!gimple_bb (use_stmt) - || (loop && !flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) - || (!loop && gimple_bb (use_stmt) != BB_VINFO_BB (bb_vinfo))) + if (!vect_same_loop_or_bb_p (last_stmt, use_stmt)) return NULL; use_lhs = gimple_assign_lhs (use_stmt); @@ -952,14 +963,8 @@ vect_operation_fits_smaller_type (gimple tree interm_type = NULL_TREE, half_type, tmp, new_oprnd, type; gimple def_stmt, new_stmt; bool first = false; - loop_vec_info loop_info = STMT_VINFO_LOOP_VINFO (vinfo_for_stmt (stmt)); - bb_vec_info bb_info = STMT_VINFO_BB_VINFO (vinfo_for_stmt (stmt)); - struct loop *loop = NULL; bool promotion; - if (loop_info) - loop = LOOP_VINFO_LOOP (loop_info); - *op0 = NULL_TREE; *op1 = NULL_TREE; *new_def_stmt = NULL; @@ -991,13 +996,9 @@ vect_operation_fits_smaller_type (gimple { first = true; if (!type_conversion_p (oprnd, stmt, false, &half_type, &def_stmt, - &promotion) - || !promotion - || !gimple_bb (def_stmt) - || (loop && !flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))) - || (!loop && gimple_bb (def_stmt) != BB_VINFO_BB (bb_info) - && gimple_code (def_stmt) != GIMPLE_PHI) - || !vinfo_for_stmt (def_stmt)) + &promotion) + || !promotion + || !vect_same_loop_or_bb_p (stmt, def_stmt)) return false; } @@ -1171,16 +1172,6 @@ vect_recog_over_widening_pattern (VEC (g tree var = NULL_TREE, new_type = NULL_TREE, tmp, new_oprnd; bool first; tree type = NULL; - loop_vec_info loop_vinfo; - struct loop *loop = NULL; - bb_vec_info bb_vinfo; - stmt_vec_info stmt_vinfo; - - stmt_vinfo = vinfo_for_stmt (stmt); - loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo); - bb_vinfo = STMT_VINFO_BB_VINFO (stmt_vinfo); - if (loop_vinfo) - loop = LOOP_VINFO_LOOP (loop_vinfo); first = true; while (1) @@ -1212,9 +1203,7 @@ vect_recog_over_widening_pattern (VEC (g } if (nuses != 1 || !is_gimple_assign (use_stmt) - || !gimple_bb (use_stmt) - || (loop && !flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) - || (!loop && gimple_bb (use_stmt) != BB_VINFO_BB (bb_vinfo))) + || !vect_same_loop_or_bb_p (stmt, use_stmt)) return NULL; /* Create pattern statement for STMT. */ @@ -1495,6 +1484,9 @@ vect_recog_widen_shift_pattern (VEC (gim || !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);