From patchwork Fri Nov 3 16:28:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 117948 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3662913qgn; Fri, 3 Nov 2017 09:28:39 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QsL6yyR9/jXO3kBwjv0hq2NPqSCTSwMgJOu8MOH8pMcQfagvHDy8w84fuBO8GGiMOqq+Tp X-Received: by 10.98.61.85 with SMTP id k82mr8287568pfa.84.1509726519495; Fri, 03 Nov 2017 09:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509726519; cv=none; d=google.com; s=arc-20160816; b=leoPGj9aXaDw3xXEjjyAlYBPnMkyRIU1zMU5osiuE4ezfJi4UT+ZmRt1pbz6nMdf71 265x1tsOlu0xlN1jkPEOtwE34bj5XRX7rwfXxA2lqDjGLSVe5j6dpsxLD8CLBX8XGAw2 KR5AeUduToVDmc2P1abeFmsikYKZ/EiLl+T5dlou4mL1/hyW0HgOrVgI33Sj7P2CFmJr 0RCIZIVNAWjAWlwc73NpSOKVEmiJjzooMPb1ezUXB5SCJiOUVKu1IrotCh9RTWRaJG77 NhGBJyigdk4rKie4L/CN3AZ73M9Zz2iE83tzQvYZwBt32gbW5tHOQ2I6/Fp5Zrapbj5O szHw== 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:cc: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=dsTutNHZrmhjSDRpzihGnjp2fbCuDYP34pMNAZHzLkI=; b=FDbzPVyKdDnHndvjWhshzSOOdHQsMBmZ9NHkWnj0m7+hFsLwXHt5CqiWFED2neyp3I VySOtlsQglSslUCPNztTaJQjlGMEDmy1NPPVlBOqU+y2OxOSmGd8gGY2t5XmuX49BevT T1Qk3kdOvTYF5dGupqb93ExZFIiIHpW7yLNdnfQAwbimeKyEfCTZwFz5CY+eY8b6Fpr7 N4Kfl4vfEeM+NjRvzhTp2P8eOYUpyUb+BNL3/F4ZLnVeNKiyNIXKlhDwPR35oAeJmQhJ cWbzk8sIU627c4mQHV2mqToWjP6Tm5otQT9wq5fR+UVasra3T7Es+366j6F43QIjuHGh ANaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=AJpEBaIP; spf=pass (google.com: domain of gcc-patches-return-465883-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-465883-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 d11si6394867pgt.43.2017.11.03.09.28.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 09:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-465883-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=AJpEBaIP; spf=pass (google.com: domain of gcc-patches-return-465883-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-465883-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:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=hx5imyzGf+agvhoGAheS5TkJyQD2+Ey1B3e83EJzqHgoF41EHW 7TSWS3xnsm5XY64Mtyf5EB7eQtfTnwNS6aFWPvi786QDHhShVngvMXJ9FT5EiEy+ UilVf89IK0k1OYIBvyQSkFSxeaHXmP0v4r2kGef7bDgtnFkYBIS7EVZPs= 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:cc:subject:date:message-id:mime-version:content-type; s= default; bh=r/ITlm0a81LwDASjMk4pt9MNSxc=; b=AJpEBaIPUd7Dyd+T5lA/ Q3NYurp5GE0jBofKvs/p5G95CYkBGrPJk9d8FO4Mm89wyjczgdw9sgAIqzvi+cIY iGejbUZWev2B6o4yqJKJ3tF162JRL+Ak04tJEuxg7J/fykhVn/MKlTVAriSUDgJs VCxLJ4/MVEn2Jks3Q+NL7tU= Received: (qmail 129276 invoked by alias); 3 Nov 2017 16:28:26 -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 129249 invoked by uid 89); 3 Nov 2017 16:28:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 16:28:24 +0000 Received: by mail-wm0-f42.google.com with SMTP id n74so3433400wmi.1 for ; Fri, 03 Nov 2017 09:28:24 -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:cc:subject:date :message-id:user-agent:mime-version; bh=dsTutNHZrmhjSDRpzihGnjp2fbCuDYP34pMNAZHzLkI=; b=ZYW3/ByS1wRIfCzTFXf25qyK7Lj4DRA4TtRNwJmUho/N+/O4WSJoSmtRc+ldzskREa hkEP3hxPvl2MmBDdfheP/GzS0E8y3ABAh4hEwVcA3L0oo1Dy3JPubVHwflUaxhLVDV+c DPKQDLUo+0kwmvsIcvF0Qrt3v9fnanKxfIseW0Lp52MNDJt0rmWvZYOjmtKD4iDoOOD0 mwlusKzeeOkURzJbWpqiDCCKg2cdt2wFhPhG5VgoUnJz/9TrxnRPYn/7cOt1U9tfOeGy TwuzLsuS8ynpo70rf6e5ZyNhZVzSQ7FSxpVvEWkvJf6KhLUCo78lCMt5B0sN4FL6nuha W3Mw== X-Gm-Message-State: AJaThX7wTox6EITkvWbaDEcqgJc+cXPuaqqNIe9SI6wd9nV9ZICPxXzI tY0QYwhhOiTO3veCeMKu8xZIrb+BkNQ= X-Received: by 10.28.21.4 with SMTP id 4mr270249wmv.84.1509726502787; Fri, 03 Nov 2017 09:28:22 -0700 (PDT) Received: from localhost (188.29.164.162.threembb.co.uk. [188.29.164.162]) by smtp.gmail.com with ESMTPSA id k185sm2270470wma.28.2017.11.03.09.28.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2017 09:28:22 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, bin.cheng@arm.com, richard.sandiford@linaro.org Cc: bin.cheng@arm.com Subject: Improve ivopts handling of forced scales Date: Fri, 03 Nov 2017 16:28:20 +0000 Message-ID: <87y3nnnx7f.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch improves the ivopts address cost calculcation for modes in which an index must be scaled rather than unscaled. Previously we would only try the scaled form if the unscaled form was valid. Many of the SVE tests rely on this when matching scaled indices. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64-linux-gnu. OK to install? Richard 2017-11-03 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-ssa-loop-ivopts.c (get_address_cost): Try using a scaled index even if the unscaled address was invalid. Don't increase the complexity of using a scale in that case. Index: gcc/tree-ssa-loop-ivopts.c =================================================================== --- gcc/tree-ssa-loop-ivopts.c 2017-11-03 12:20:07.041206480 +0000 +++ gcc/tree-ssa-loop-ivopts.c 2017-11-03 12:20:07.193201997 +0000 @@ -4333,18 +4333,25 @@ get_address_cost (struct ivopts_data *da machine_mode addr_mode = TYPE_MODE (type); machine_mode mem_mode = TYPE_MODE (TREE_TYPE (*use->op_p)); addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (use->iv->base)); + /* Only true if ratio != 1. */ + bool ok_with_ratio_p = false; + bool ok_without_ratio_p = false; if (!aff_combination_const_p (aff_inv)) { parts.index = integer_one_node; /* Addressing mode "base + index". */ - if (valid_mem_ref_p (mem_mode, as, &parts)) + ok_without_ratio_p = valid_mem_ref_p (mem_mode, as, &parts); + if (ratio != 1) { parts.step = wide_int_to_tree (type, ratio); /* Addressing mode "base + index << scale". */ - if (ratio != 1 && !valid_mem_ref_p (mem_mode, as, &parts)) + ok_with_ratio_p = valid_mem_ref_p (mem_mode, as, &parts); + if (!ok_with_ratio_p) parts.step = NULL_TREE; - + } + if (ok_with_ratio_p || ok_without_ratio_p) + { if (maybe_nonzero (aff_inv->offset)) { parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); @@ -4444,7 +4451,9 @@ get_address_cost (struct ivopts_data *da if (parts.symbol != NULL_TREE) cost.complexity += 1; - if (parts.step != NULL_TREE && !integer_onep (parts.step)) + /* Don't increase the complexity of adding a scaled index if it's + the only kind of index that the target allows. */ + if (parts.step != NULL_TREE && ok_without_ratio_p) cost.complexity += 1; if (parts.base != NULL_TREE && parts.index != NULL_TREE) cost.complexity += 1;