From patchwork Mon Jul 3 07:40:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 106884 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5471576qge; Mon, 3 Jul 2017 00:44:04 -0700 (PDT) X-Received: by 10.99.131.193 with SMTP id h184mr9170977pge.80.1499067844394; Mon, 03 Jul 2017 00:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499067844; cv=none; d=google.com; s=arc-20160816; b=ro30JKpHuw/SF+UIctYubCALzq9temCl5JsUoWk7COr6PK1C2uyWhn0MRfCXtZ/mEj nRaAAUpmCMHZuS/pH+3CCIAmEupzczGUb9CtDW2+I2Vk72KSEsfTNzTC46nVIW5wDnI3 s4dREUQdibndEuCR0IZxsv1TgJRsHF1aqXTdzEntSl5ZrHxDUZWe8r3t6D9n+Wk7g5Cx fcVqEUJ24r1MXxXV5Bd3c1nIXw1Hefz2aAviPwJSZwa2SfWqvL4YbrLH53wfdwFQICUc 5ObGSFXfGuSa7fcuihxZSYau7Zh3dOAV7BDQPtdXfQp23vJz8xkbFZ6pv8Bf7/l3oBNN YQ2g== 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=PEqGjfVT5XCD7dL4YP9ZPDN88ZoYBLbWUfdrHbpZWe4=; b=ob6QNi56D8yK1gVcN4Dp+ffS6NAId0+G086tbOGLhwtCBmZBLaClzWhc0Rvz7nSTX0 4PkhgJZhDfwOPkb8vF1a+bNDjj0N5MjXMeKPAIptoFBof7qyGJaxiO7FjtEy/GLEXFeD ERAVrORbpznrDZKKXiUUOd4x4U7Yjov+eTLbx4E4wA/tLEqoAKr2/L/w2/4KQ2loEs6a dqwnI7KvNoI2+W9KoeHRajVpYbjt08XlmcT/MlJHTXCRkzw2IvQtROp2R/lKXum/UFzy BZh1IF2v0FIuYsV+Nh/lX0dYV+4bqXjnSZhKOToF/wo5ks1NEjgwUpFYGu5cfctx75Mk gCoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=GNklLQKJ; spf=pass (google.com: domain of gcc-patches-return-457412-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457412-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 u3si11734372pfl.348.2017.07.03.00.44.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jul 2017 00:44:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-457412-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.b=GNklLQKJ; spf=pass (google.com: domain of gcc-patches-return-457412-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-457412-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=SujS0hmTWiVB7yD822YCHrpjJWh0677uNwN2whSbM+onZ1Skeex/B abZ5U9i0D0zy9juoJ6VdDx0EKjzBO+/owPktvgfD3XhHdI2GFWjI07tapb7l9vY3 oYj13zgcG7dLH14PCnphxx7DdFnnpew7LnC50QcatpMFbXGgYGklHU= 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=ybmSA6Y+VX9n+WFrP2o6CbnCnWw=; b=GNklLQKJ98lfcPyJtbaE s/qOZ5H+gMo8ATyl3vIFvbu/VpZ6YD1dAtr9tJYVE9zVWGj8BxSKjgqsNqwGoJ5y LRcGsd2dOLoJ3rM0+6cHOoIvPLfjeMDDgtxqSu+CD03Gf4Vjzhwaihp/pnEpyM+a 2YEuJlflovxFraoM6XEjljM= Received: (qmail 57273 invoked by alias); 3 Jul 2017 07:43:29 -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 54883 invoked by uid 89); 3 Jul 2017 07:40:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Cap, 7528, Hx-languages-length:5142, 40516 X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jul 2017 07:40:30 +0000 Received: by mail-wr0-f173.google.com with SMTP id c11so229722999wrc.3 for ; Mon, 03 Jul 2017 00:40:30 -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=PEqGjfVT5XCD7dL4YP9ZPDN88ZoYBLbWUfdrHbpZWe4=; b=BLF4Q7FzGLvZ8s/rsX5+Lj7SJ9s9JMNLmJNuGQzqJ007o/tP/OjDQoEYe/7UQvPZ77 p6oxWCbWa3Fj4wkx6RrjVgYzNKNUkYdDeT1q0wVLB27yZA6+C25OXl6OFovQVmcBFPbV lqDs0qWn1L0OG3+s0xSpebpklMP7Ka9s7Smh9V4PM/uM52puIiPhGMTmUkYl24ZMLrcx m8lur9Fmjo4xRsIEFBtHkljMJAfOnHtcOfXRIAFTW/DBBiOkRgmBonQJMFRTSfAASZFE ynx6eYEfDz/BagvimkFiQJnBt7E3BwsD+uODxuvNbxBYIs3Dsi8AaLIdJKGXnQmNvmaC vWmw== X-Gm-Message-State: AIVw110Ib6wj3DAFwPOuyAtmJpaH6R+xHFfnDoyVu5OG5LJhs4y8YRjw DcO5SqVmcM7+hqbAJLGAog== X-Received: by 10.223.161.204 with SMTP id v12mr561724wrv.125.1499067628215; Mon, 03 Jul 2017 00:40:28 -0700 (PDT) Received: from localhost (92.40.248.165.threembb.co.uk. [92.40.248.165]) by smtp.gmail.com with ESMTPSA id 32sm19678157wry.31.2017.07.03.00.40.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jul 2017 00:40:27 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [6/7] Add a helper for getting the overall alignment of a DR Date: Mon, 03 Jul 2017 08:40:25 +0100 Message-ID: <87k23qx91y.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This combines the information from previous patches to give a guaranteed alignment for the DR as a whole. This should be a bit safer than using base_element_aligned, since that only really took the base into account (not the init or offset). Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2017-07-03 Richard Sandiford gcc/ * tree-data-ref.h (dr_alignment): Declare. * tree-data-ref.c (dr_alignment): New function. * tree-vectorizer.h (dataref_aux): Remove base_element_aligned. * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Don't set it. * tree-vect-stmts.c (vectorizable_store): Use dr_alignment. Index: gcc/tree-data-ref.h =================================================================== --- gcc/tree-data-ref.h 2017-07-03 08:17:58.418572314 +0100 +++ gcc/tree-data-ref.h 2017-07-03 08:18:29.775412176 +0100 @@ -405,6 +405,16 @@ extern bool compute_all_dependences (vec vec, bool); extern tree find_data_references_in_bb (struct loop *, basic_block, vec *); +extern unsigned int dr_alignment (innermost_loop_behavior *); + +/* Return the alignment in bytes that DR is guaranteed to have at all + times. */ + +inline unsigned int +dr_alignment (data_reference *dr) +{ + return dr_alignment (&DR_INNERMOST (dr)); +} extern bool dr_may_alias_p (const struct data_reference *, const struct data_reference *, bool); Index: gcc/tree-data-ref.c =================================================================== --- gcc/tree-data-ref.c 2017-07-03 08:17:58.418572314 +0100 +++ gcc/tree-data-ref.c 2017-07-03 08:17:59.017546839 +0100 @@ -4769,6 +4769,30 @@ find_data_references_in_loop (struct loo return NULL_TREE; } +/* Return the alignment in bytes that DRB is guaranteed to have at all + times. */ + +unsigned int +dr_alignment (innermost_loop_behavior *drb) +{ + /* Get the alignment of BASE_ADDRESS + INIT. */ + unsigned int alignment = drb->base_alignment; + unsigned int misalignment = (drb->base_misalignment + + TREE_INT_CST_LOW (drb->init)); + if (misalignment != 0) + alignment = MIN (alignment, misalignment & -misalignment); + + /* Cap it to the alignment of OFFSET. */ + if (!integer_zerop (drb->offset)) + alignment = MIN (alignment, drb->offset_alignment); + + /* Cap it to the alignment of STEP. */ + if (!integer_zerop (drb->step)) + alignment = MIN (alignment, drb->step_alignment); + + return alignment; +} + /* Recursive helper function. */ static bool Index: gcc/tree-vectorizer.h =================================================================== --- gcc/tree-vectorizer.h 2017-07-03 08:17:58.419572272 +0100 +++ gcc/tree-vectorizer.h 2017-07-03 08:18:09.031167838 +0100 @@ -752,8 +752,6 @@ struct dataref_aux { int misalignment; /* If true the alignment of base_decl needs to be increased. */ bool base_misaligned; - /* If true we know the base is at least vector element alignment aligned. */ - bool base_element_aligned; tree base_decl; }; Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2017-07-03 08:17:58.419572272 +0100 +++ gcc/tree-vect-data-refs.c 2017-07-03 08:17:59.018546796 +0100 @@ -731,12 +731,6 @@ vect_compute_data_ref_alignment (struct unsigned int base_alignment = drb->base_alignment; unsigned int base_misalignment = drb->base_misalignment; unsigned HOST_WIDE_INT vector_alignment = TYPE_ALIGN_UNIT (vectype); - unsigned HOST_WIDE_INT element_alignment - = TYPE_ALIGN_UNIT (TREE_TYPE (vectype)); - - if (base_alignment >= element_alignment - && (base_misalignment & (element_alignment - 1)) == 0) - DR_VECT_AUX (dr)->base_element_aligned = true; if (drb->offset_alignment < vector_alignment || !step_preserves_misalignment_p @@ -797,7 +791,6 @@ vect_compute_data_ref_alignment (struct DR_VECT_AUX (dr)->base_decl = base; DR_VECT_AUX (dr)->base_misaligned = true; - DR_VECT_AUX (dr)->base_element_aligned = true; base_misalignment = 0; } unsigned int misalignment = (base_misalignment Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-07-03 08:07:42.512875037 +0100 +++ gcc/tree-vect-stmts.c 2017-07-03 08:17:59.019546754 +0100 @@ -6359,11 +6359,7 @@ vectorizable_store (gimple *stmt, gimple misalign = 0; else if (DR_MISALIGNMENT (first_dr) == -1) { - if (DR_VECT_AUX (first_dr)->base_element_aligned) - align = TYPE_ALIGN_UNIT (elem_type); - else - align = get_object_alignment (DR_REF (first_dr)) - / BITS_PER_UNIT; + align = dr_alignment (vect_dr_behavior (first_dr)); misalign = 0; TREE_TYPE (data_ref) = build_aligned_type (TREE_TYPE (data_ref), @@ -7435,11 +7431,7 @@ vectorizable_load (gimple *stmt, gimple_ } else if (DR_MISALIGNMENT (first_dr) == -1) { - if (DR_VECT_AUX (first_dr)->base_element_aligned) - align = TYPE_ALIGN_UNIT (elem_type); - else - align = (get_object_alignment (DR_REF (first_dr)) - / BITS_PER_UNIT); + align = dr_alignment (vect_dr_behavior (first_dr)); misalign = 0; TREE_TYPE (data_ref) = build_aligned_type (TREE_TYPE (data_ref),