From patchwork Thu Sep 14 11:25:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 112545 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp626935qgf; Thu, 14 Sep 2017 04:25:37 -0700 (PDT) X-Received: by 10.98.32.86 with SMTP id g83mr20903787pfg.313.1505388337790; Thu, 14 Sep 2017 04:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505388337; cv=none; d=google.com; s=arc-20160816; b=DDjveV/pSG1u63YWzRDyK4QtW15CZe70b3qsmpWz7rpt/cI2U+r7nmnJ+RDkyXKEGy xKr5cFzREinNmA7cQifzZefOlLhB87AWo+TYbMjzRAfSXNFH+LE+TcOjeyf7Shji9vJp AMvNpL+6f8Dd8ZZ9tSdPASO61+a3NjvQSOAoTWcRcPD31fgScFr+HgEvNq0XiPbvWTsL g70us6zW8xd0AacbyZBN271z9siq3W9lqFLdGZ5FaWjfQVo+JkdOwg2cg5J1i5RXGUXI EJvKi/bvMVibkbmeC7/+OXWTZdTQ89KJ4GF/epaJgdSrwSZzaPj633yB5aeqoLa9x7YY dzqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=UAMwbnaYaOQMePGEtDYLp017QBgaFQaeynhMWQPDWZY=; b=NM1p1XrbhKCB4BVIMT5dRl5SNEbatP5KO0h41JlnLGX+W6+mfb3IYZR3HYh0qSvvg+ sqr0OhF3orGk182dHAWfBE9giWSRfswAZ6/+IIaxCc/YE6gc/P9hNgoY7VDgwZGgc0cT aI9LyjL7iOKjeDeP+L5ul5KT2Rt0Xp4al+dO5Aaj6NiubJQ758eSxMSkK/RpsnvSwaDC a233OCwEb7fCCBS4+VAPnE8shv+ibzPsf3ta2iZ3EhOM1r/z/5414R7F9ASN2F3vUASj +1k2Tv/QsjI/EcGZcVyqYzoz3T+8zECO/cn/3j62r9TpDWQZ6xSznJaMeK5NJIksDDjh eJGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZI5uNOts; spf=pass (google.com: domain of gcc-patches-return-462125-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462125-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s4si3028605pgr.105.2017.09.14.04.25.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 04:25:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462125-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZI5uNOts; spf=pass (google.com: domain of gcc-patches-return-462125-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462125-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=fsvF0mhEkKxtAqHlR+GH4r56B0sJYSnjBNFKbmmATJzu8+W5DcapK 44OJyloZarh7j2bAGhkjMmn+E907aw/opmAgqJHXRdZptj/W1JjdIZmnE8Olxuom S5PUYdX+RUZy7alnWsJ+gJd3BZqdHI/BmleF+eATXKk6b8mOlwQ6pQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=sLXPZewdDY+7JVVQTmSB05YjVqk=; b=ZI5uNOtsgTYPewaPFexx 0FgHt/5HIXYHqX7lQrlMeraaxrXfGyo6O/QqucJ6Es9XzhficjgfXKyFkA7GnMog djGZ0GKXCN77zxq9i0o7eSeB0phAKW4BT0XgEtXQva8qJZMvui9S/3mlDAcBSFWj oZrYGL4fQda+BLBl/BCFsv0= Received: (qmail 44210 invoked by alias); 14 Sep 2017 11:25:23 -0000 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 Received: (qmail 42415 invoked by uid 89); 14 Sep 2017 11:25:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2724, Later X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Sep 2017 11:25:20 +0000 Received: by mail-wr0-f170.google.com with SMTP id a43so5662612wrc.0 for ; Thu, 14 Sep 2017 04:25:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=UAMwbnaYaOQMePGEtDYLp017QBgaFQaeynhMWQPDWZY=; b=pQP232dtGCNClcSb3waS1zTHVB4gE8N9qP+CpM+RWPp5dfpmI9AIWXyXeLqKM8db3W wMD0qX5AaoSDN1TS05nBx3ze1k1Bkq/UZFYNhS0ctxA66B/0PxoUZUGfj2d1e4+ITmei Xfo+h3cLL/kco4sUWkxw6ZlC4dQyOHTsjyH4WyislA/Xw6ypiPb5sgbU+6XzOULDTjMD LytGcPAJ2lfI5POsDZg0ds2yaM7oyK5fwjoHEv2wIZ9SDSrDFaG27RXNxgQmWzHZYeLo TVbP1ym7a+CPINPUQTR2L3rnlZ8BgXJ9J5OSxn6A3+9HfF3eyCilPG0r6akGDScSSKR0 vocw== X-Gm-Message-State: AHPjjUinglkHusG+Dks0L/PiZX6rID1Emocm6dYUNB5S2TzOeAhoC/s5 Kd5R/t5+23PU7j1bwLRptQ== X-Google-Smtp-Source: ADKCNb5kOpzJantomJVQTSW7OSxaaGZAOwH9dciAUMt1rGbldNDtKwm4h6wMtSGt18sCyTVxYKWA3A== X-Received: by 10.223.165.73 with SMTP id j9mr18236161wrb.62.1505388318497; Thu, 14 Sep 2017 04:25:18 -0700 (PDT) Received: from localhost (92.40.248.70.threembb.co.uk. [92.40.248.70]) by smtp.gmail.com with ESMTPSA id 5sm10143316wrb.9.2017.09.14.04.25.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Sep 2017 04:25:17 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Make more use of gimple-fold.h in tree-vect-loop.c Date: Thu, 14 Sep 2017 12:25:15 +0100 Message-ID: <87fubpwmhw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes the vectoriser use the gimple-fold.h routines in more cases, instead of vect_init_vector. Later patches want to use the same interface to handle variable-length vectors. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. OK to install? Richard 2017-09-14 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vect-loop.c (vectorizable_induction): Use gimple_build instead of vect_init_vector. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-09-14 11:26:37.599804415 +0100 +++ gcc/tree-vect-loop.c 2017-09-14 11:27:16.962234838 +0100 @@ -6839,18 +6839,21 @@ vectorizable_induction (gimple *phi, { /* iv_loop is the loop to be vectorized. Generate: vec_step = [VF*S, VF*S, VF*S, VF*S] */ + gimple_seq seq = NULL; if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr))) { expr = build_int_cst (integer_type_node, vf); - expr = fold_convert (TREE_TYPE (step_expr), expr); + expr = gimple_build (&seq, FLOAT_EXPR, TREE_TYPE (step_expr), expr); } else expr = build_int_cst (TREE_TYPE (step_expr), vf); - new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr), - expr, step_expr); - if (TREE_CODE (step_expr) == SSA_NAME) - new_name = vect_init_vector (phi, new_name, - TREE_TYPE (step_expr), NULL); + new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr), + expr, step_expr); + if (seq) + { + new_bb = gsi_insert_seq_on_edge_immediate (pe, seq); + gcc_assert (!new_bb); + } } t = unshare_expr (new_name); @@ -6899,6 +6902,7 @@ vectorizable_induction (gimple *phi, if (ncopies > 1) { + gimple_seq seq = NULL; stmt_vec_info prev_stmt_vinfo; /* FORNOW. This restriction should be relaxed. */ gcc_assert (!nested_in_vect_loop); @@ -6907,15 +6911,18 @@ vectorizable_induction (gimple *phi, if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr))) { expr = build_int_cst (integer_type_node, nunits); - expr = fold_convert (TREE_TYPE (step_expr), expr); + expr = gimple_build (&seq, FLOAT_EXPR, TREE_TYPE (step_expr), expr); } else expr = build_int_cst (TREE_TYPE (step_expr), nunits); - new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr), - expr, step_expr); - if (TREE_CODE (step_expr) == SSA_NAME) - new_name = vect_init_vector (phi, new_name, - TREE_TYPE (step_expr), NULL); + new_name = gimple_build (&seq, MULT_EXPR, TREE_TYPE (step_expr), + expr, step_expr); + if (seq) + { + new_bb = gsi_insert_seq_on_edge_immediate (pe, seq); + gcc_assert (!new_bb); + } + t = unshare_expr (new_name); gcc_assert (CONSTANT_CLASS_P (new_name) || TREE_CODE (new_name) == SSA_NAME);