From patchwork Fri Sep 15 01:27:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 112666 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp68844qgf; Thu, 14 Sep 2017 18:27:34 -0700 (PDT) X-Received: by 10.101.86.133 with SMTP id v5mr9884317pgs.249.1505438853928; Thu, 14 Sep 2017 18:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505438853; cv=none; d=google.com; s=arc-20160816; b=cs26v9fELtzTVUpB64BDuuUWfKuO2zKI8K3pg0tm9WatwbwMGz9NerBPGZInxWQt3p 6kTzx5U2etAMlnsasBnnqj5aIYL3J4PoGLEqoWklqALErTunkNRWgbf7J0E1PgQ1kSI0 3OHSDYVFaqiLsou2YVUClR4+nNanMOiAreyZfeeHds0NtxNbR13vRIouWk2Ys4Mozg/q 9UqKlPGKnrs3e2dbWA1fmEo+uS/krJFtEV/Fg/0eIEwtg7TPN3fh/iaVtDm8uI0VQSSn N1B24cOiGLudJjttv7c61dpMP5rGUHxKwLwP26kkFo1NM+3o21l/WpL7LzsJ8xblLbk8 p/Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=6MPDYOo3f/puIH6TqK14g6/GZ4vBKdW5DJ3JmA0WjDA=; b=oAGbTe6ck8LcHQPLy3QKQM6w0ZzoIyQlyDFIKFhM/lTTQONbcBot5gsb1qQ7y6oCOs t4sOI9L42am6RJFxD7atSLMGgeXexWJ4BsderBjGxRD0rcxIvJkKjHZp6ZTl9dR9tKuO sWENzlwHER+7pMSKDzQHxi4juNqa3KdV6Z6y9n+r72SyTW3o1wSfCinYvhcpXT4LcGOC 0YNiokggMAw/MEOHVUJ9yW9hPGT/DBVvASWzawwu9XU1a8xLYXc2kJLB7E3hQv/lAU6a 6GkiJOBnZ+1SQG+9VzuSDDwf9i8U4r1oYFCQJfu15OpqLp9TPeP4njiN9Z6cgPBSJEHZ 8UdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=q7P6YIeo; spf=pass (google.com: domain of gcc-patches-return-462189-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462189-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 a2si11528917pgt.611.2017.09.14.18.27.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 18:27:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462189-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=q7P6YIeo; spf=pass (google.com: domain of gcc-patches-return-462189-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462189-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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=ggQpxgfiFnsmeH0rF3ZGibmxXg53Pywxd3hrqEXHNh68w3 bruemF3i+Ephhii5XfugZc9Jcn/ATZcVA4jmRpkfY1SexZJBpe9xntLD7D7kDbm2 CpGQaTR0ZU77WzouCo97GQkD0mMW9fmKiEavV4pl42mpGTlLZIHYKc/4RxFaI= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=JaUq8xBvOk0nCekCuniDeJs/7/8=; b=q7P6YIeoNsWEcdmjXy7u MZ4MjvHa2/BOBg9I6IR6iUNI8JChevkT6YeyGY7vvWdOI96RP3QFojQEVQ1YKLHJ d0UWitCt90d04pNo9wKKBeaTCCFiHWiMyqG3G3FGggCOMooM7CkCAUXwV2SfUGGq 6FTnRSMkIVSWq/s6iXIT7LU= Received: (qmail 104526 invoked by alias); 15 Sep 2017 01:27:21 -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 104517 invoked by uid 89); 15 Sep 2017 01:27:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f182.google.com Received: from mail-qt0-f182.google.com (HELO mail-qt0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 01:27:19 +0000 Received: by mail-qt0-f182.google.com with SMTP id q4so982476qtq.8 for ; Thu, 14 Sep 2017 18:27:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=1CGfYS5m6hl48bwfiD8NOudEnkDWW99CkDLowbe7tMg=; b=DQT0dliMJ4l7mS+7R9dJ8yP0dnRKieWj8Bv5a2Jd9F3CcOz14YPtaLtITsvTGcAtwk bdsh6g9392s5s5F3wsqJJ2TvThQsse+w00RgORSNdKlFmsbTvBi6aiiHk5GdRQEdDVdw J+BBh3yOK6BqidX6cLoRfzIQ50YR6y3h+bEyZBBYhHx2pyB0i0+KolZbqAWj2w9orU7s 1skkXGcy4cUfAkCdGgBtKRzEhV1U7KlSAxd52uBZI2wCp6ZAzDydUPdbq3W1c1rrlccQ XtGfiooO7eczOZhrp80S2TM0yMgJfFHCK1SYxaOcHD0xpPGXAZ28nBmtOFZIE7SbSV+m NH8w== X-Gm-Message-State: AHPjjUjx9QwxZ4/WdFINpGbrb7xzjCdXe0Ng1cTT1SRDiTKnC3yGD52s ZP/aZTZUt8XIlo5WqsrwuE/tdbKSltcEtFj3qzOCqY4pxNg= X-Google-Smtp-Source: AOwi7QDmlCgK3PFVNOsV3DbANvqV9lwDTpVhwTJEnwUnm0ZOwjUtCSn/WFSFj68EoVmwaA7Beuq63kEj4HyRO8q7evU= X-Received: by 10.237.37.228 with SMTP id y33mr25177351qtc.79.1505438837957; Thu, 14 Sep 2017 18:27:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.37.211 with HTTP; Thu, 14 Sep 2017 18:27:15 -0700 (PDT) From: Kugan Vivekanandarajah Date: Fri, 15 Sep 2017 11:27:15 +1000 Message-ID: Subject: [RFC][PATCH 1/5] Add separate parms for rtl unroller To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes This patch adds separate params for rtl unroller so that they can be tunned accordingly. Default values I have are based on some testing on aarch64. I am happy to leave it as the current value and set them in the back-end. Thanks, Kugan gcc/ChangeLog: 2017-09-12 Kugan Vivekanandarajah * loop-unroll.c (decide_unroll_constant_iterations): Use new params. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. * params.def (DEFPARAM): Separate and add new params for rtl unroller. >From a899caf9f82767de3db556225b28dc52a81d5967 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Mon, 14 Aug 2017 10:12:09 +1000 Subject: [PATCH 1/5] add parms for rtl unroller --- gcc/loop-unroll.c | 24 ++++++++++++------------ gcc/params.def | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index 84145bb..871558c 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -360,13 +360,13 @@ decide_unroll_constant_iterations (struct loop *loop, int flags) /* nunroll = total number of copies of the original loop body in unrolled loop (i.e. if it is 2, we have to duplicate loop body once. */ - nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns; + nunroll = PARAM_VALUE (PARAM_MAX_UNROLLEDP_INSNS) / loop->ninsns; nunroll_by_av - = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns; + = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLEDP_INSNS) / loop->av_ninsns; if (nunroll > nunroll_by_av) nunroll = nunroll_by_av; - if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES)) - nunroll = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES); + if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES)) + nunroll = PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES); if (targetm.loop_unroll_adjust) nunroll = targetm.loop_unroll_adjust (nunroll, loop); @@ -664,12 +664,12 @@ decide_unroll_runtime_iterations (struct loop *loop, int flags) /* nunroll = total number of copies of the original loop body in unrolled loop (i.e. if it is 2, we have to duplicate loop body once. */ - nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns; - nunroll_by_av = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns; + nunroll = PARAM_VALUE (PARAM_MAX_UNROLLEDP_INSNS) / loop->ninsns; + nunroll_by_av = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLEDP_INSNS) / loop->av_ninsns; if (nunroll > nunroll_by_av) nunroll = nunroll_by_av; - if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES)) - nunroll = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES); + if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES)) + nunroll = PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES); if (targetm.loop_unroll_adjust) nunroll = targetm.loop_unroll_adjust (nunroll, loop); @@ -1158,13 +1158,13 @@ decide_unroll_stupid (struct loop *loop, int flags) /* nunroll = total number of copies of the original loop body in unrolled loop (i.e. if it is 2, we have to duplicate loop body once. */ - nunroll = PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS) / loop->ninsns; + nunroll = PARAM_VALUE (PARAM_MAX_UNROLLEDP_INSNS) / loop->ninsns; nunroll_by_av - = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLED_INSNS) / loop->av_ninsns; + = PARAM_VALUE (PARAM_MAX_AVERAGE_UNROLLEDP_INSNS) / loop->av_ninsns; if (nunroll > nunroll_by_av) nunroll = nunroll_by_av; - if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLL_TIMES)) - nunroll = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES); + if (nunroll > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES)) + nunroll = PARAM_VALUE (PARAM_MAX_UNROLLP_TIMES); if (targetm.loop_unroll_adjust) nunroll = targetm.loop_unroll_adjust (nunroll, loop); diff --git a/gcc/params.def b/gcc/params.def index 805302b..c8b0a2b 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -302,6 +302,23 @@ DEFPARAM(PARAM_MAX_PEELED_INSNS, "max-peeled-insns", "The maximum number of insns of a peeled loop.", 100, 0, 0) + +DEFPARAM(PARAM_MAX_UNROLLEDP_INSNS, + "max-partial-unrolled-insns", + "The maximum number of instructions to consider to unroll in a loop by rtl unroller.", + 100, 0, 0) +/* This parameter limits how many times the loop is unrolled depending + on number of insns really executed in each iteration. */ +DEFPARAM(PARAM_MAX_AVERAGE_UNROLLEDP_INSNS, + "max-partial-average-unrolled-insns", + "The maximum number of instructions to consider to unroll in a loop on average by rtl unroller.", + 40, 0, 0) +/* The maximum number of unrollings of a single loop. */ +DEFPARAM(PARAM_MAX_UNROLLP_TIMES, + "max-partial-unroll-times", + "The maximum number of unrollings of a single loop by rtl unroller.", + 4, 0, 0) + /* The maximum number of peelings of a single loop. */ DEFPARAM(PARAM_MAX_PEEL_TIMES, "max-peel-times", -- 2.7.4 From patchwork Fri Sep 15 01:28:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 112667 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp69804qgf; Thu, 14 Sep 2017 18:29:07 -0700 (PDT) X-Received: by 10.84.136.34 with SMTP id 31mr26626097plk.174.1505438947012; Thu, 14 Sep 2017 18:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505438947; cv=none; d=google.com; s=arc-20160816; b=FMgIMhIsrtI4rqBEGAgi3L9vqJnnVpqBk5UQkBVdofxngkgLU7WKhBe19Zcfc9mGqx ud1l1lQVt3J9F065YONOoj331mpKI3vYlwGJpMUT/UozssaRamXQ6tMRfN4nfNyRsp7x ZjGG3AliCTmghrTEBJfQ7qPpCJZ2T2algHoPuW7A1gzgBC05ehKQSlYFH4UnijlOmh7n 8BF9uui1sH75UVETqj1lKtjXN95SqNQQ1LkgIoDd/ggE9A50P/jbmeVIC+0jH1ppIEk0 eL3oSdjm52WnSmc5yVJPQKa1qx27PPEOXoubmMdCXJ+24QdhpC8g0foH/bgxfUjG0JhU H09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=1qln/hu8wBXQptxNO2+ANzwwAlSHlHFCAslWUKGftfY=; b=tFQcx+pWGcSTZsKeXlOlz2XYqo4mxXaCQ1VmTRyJcSmzPwHCsOqbclr0LP4GexmSvl VAOejQLc4cEZ95f5YD7XztOAKRLabFrv6qloC9Nfjzbf2kpS6w3j+mB58GR89c6E8fYg 5Aeihr4cK4Ivmahspx08l8/oBKoS2yQo9dKF7p5v5rx3h0hmo195oyRoge9rkBu4pWhG jatwT6X9nW66NGBIydODz+vE+XcPjvBb/S9TwmeHlo9n7phGlvfk/Q7r2nWjvOl9OYuu YyrNFfzl5Mob2j5c2EYxMdZwCq4U9dqBDEwpbNwDwFw5uxzRNSIkbf6JvjAEoTgjdYVK eedw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TH9lbsVB; spf=pass (google.com: domain of gcc-patches-return-462190-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462190-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 d5si2913277pfg.34.2017.09.14.18.29.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 18:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462190-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=TH9lbsVB; spf=pass (google.com: domain of gcc-patches-return-462190-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462190-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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UbEbMsPf9ff1gBjGuZFTjTfSKAmxtUoccdmWk1BS0jrRpT a/6PqdbKz72E1FvVUrdgH97E1yNzPjeLEcVWPj+xLZNvy3vV/HFy3F4xGSeHVUf+ iQc5BT18a+dKbPOL0sXE/77AF8GbUvJfGvlH43uCbGHJin35Nesw8Y0gugHyw= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=oTOLq5chnGuF+Q3ZK9HnAP9oi9A=; b=TH9lbsVBCbkzhxqfUB3m D1VEikMpGRGRWUCsh7EiGsS9uVCCAk1nZsKuhzzmR/+VdcMxZyV6Ujp/vSXEPz/J 8l4ZB9vcw+8VZtk94vi1LIDIKL6oWVT4Vbu//NOlUBFx3c1XfhAZWWcYBZD0DdMc LrNz3MmQtRwSVv3vCVFGgwA= Received: (qmail 106511 invoked by alias); 15 Sep 2017 01:28:51 -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 106499 invoked by uid 89); 15 Sep 2017 01:28:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=5427 X-HELO: mail-qk0-f177.google.com Received: from mail-qk0-f177.google.com (HELO mail-qk0-f177.google.com) (209.85.220.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 01:28:49 +0000 Received: by mail-qk0-f177.google.com with SMTP id u7so930887qku.13 for ; Thu, 14 Sep 2017 18:28:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=EI8CoFG15kcvi9I332ljBuADU17C5rTcQZMFIC5DFpA=; b=p/V6ouzTMykhvwgBaSUh0ZMfMvYBQxveFJO30i1ihoHBvPEu9yiwXKOeLME0/inDeh a0ph8yaA1PypIZoAJFEc3EFI0EPizukeOs1KmQ4ftTeWZ9NFgWs+tIz5orxlmqE5Kzul CT1bCDrXum36rMMgn9oQYQW9IdUTeT5PBMOgBgi/ZOmH9zosK13Ugc2j9EyHIHiNDxKq g4yWga4tQZd+GZbuhmIfSw/KnoNjwc7cVfTVg7XK/QMeECTQvunpbqrTfpiBXoKc/haD G/bjuqoZJWyhvKaOwHbzkrGV9UJFnDSPepko19+OZfChki7HcUo6nmwpj6IcprjAf9/G aFMw== X-Gm-Message-State: AHPjjUiNVnE9BW7sdoEa6wFTrA7O1dr+WUPTmD3VuJMlycBHuJ7Q4bFQ 2xTfWr9HGHiB9B1yGXcgbwJ9RDagRyiB4QQoCMlZIBvQZQw= X-Google-Smtp-Source: AOwi7QCtmwPlCj9hBfRuoVIr0Fd2TzNtEub4PWsPN+Iodo2lsZHfGnQO5TzxuvfFpveCm2n5wk5OJ2UQwPERs7HWCPs= X-Received: by 10.55.170.216 with SMTP id t207mr5150857qke.232.1505438927988; Thu, 14 Sep 2017 18:28:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.37.211 with HTTP; Thu, 14 Sep 2017 18:28:47 -0700 (PDT) From: Kugan Vivekanandarajah Date: Fri, 15 Sep 2017 11:28:47 +1000 Message-ID: Subject: [RFC][AARCH64][PATCH 2/5]: Add number of hw prefetchers available to cpu_prefetch_tune To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes This patch adds number of hw prefetchers available to cpu_prefetch_tune so it can be used in loop unrolling decisions. Thanks, Kugan gcc/ChangeLog: 2017-09-12 Kugan Vivekanandarajah * config/aarch64/aarch64-protos.h (struct cpu_prefetch_tune): Add new field hw_prefetchers_avail. * config/aarch64/aarch64.c: Add values for hw_prefetchers_avail. >From 07de7988c4c36a8eb262d53c259dc17d20d3b770 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 25 Aug 2017 10:02:45 +1000 Subject: [PATCH 2/5] Add hw prefetchers to cpu_prefetch_tune --- gcc/config/aarch64/aarch64-protos.h | 1 + gcc/config/aarch64/aarch64.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index e397ff4..a182105 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -211,6 +211,7 @@ struct cpu_prefetch_tune const int l1_cache_line_size; const int l2_cache_size; const int default_opt_level; + const int hw_prefetchers_avail; }; struct tune_params diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index d753666..7d1ee70 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -533,7 +533,8 @@ static const cpu_prefetch_tune generic_prefetch_tune = -1, /* l1_cache_size */ -1, /* l1_cache_line_size */ -1, /* l2_cache_size */ - -1 /* default_opt_level */ + -1, /* default_opt_level */ + -1 /* default hw_prefetchers_avail */ }; static const cpu_prefetch_tune exynosm1_prefetch_tune = @@ -542,7 +543,8 @@ static const cpu_prefetch_tune exynosm1_prefetch_tune = -1, /* l1_cache_size */ 64, /* l1_cache_line_size */ -1, /* l2_cache_size */ - -1 /* default_opt_level */ + -1, /* default_opt_level */ + -1 /* default hw_prefetchers_avail */ }; static const cpu_prefetch_tune qdf24xx_prefetch_tune = @@ -551,7 +553,8 @@ static const cpu_prefetch_tune qdf24xx_prefetch_tune = 32, /* l1_cache_size */ 64, /* l1_cache_line_size */ 1024, /* l2_cache_size */ - 3 /* default_opt_level */ + 3, /* default_opt_level */ + 7 /* hw_prefetchers_avail */ }; static const cpu_prefetch_tune thunderxt88_prefetch_tune = @@ -560,7 +563,8 @@ static const cpu_prefetch_tune thunderxt88_prefetch_tune = 32, /* l1_cache_size */ 128, /* l1_cache_line_size */ 16*1024, /* l2_cache_size */ - 3 /* default_opt_level */ + 3, /* default_opt_level */ + -1 /* default hw_prefetchers_avail */ }; static const cpu_prefetch_tune thunderx_prefetch_tune = @@ -569,7 +573,8 @@ static const cpu_prefetch_tune thunderx_prefetch_tune = 32, /* l1_cache_size */ 128, /* l1_cache_line_size */ -1, /* l2_cache_size */ - -1 /* default_opt_level */ + -1, /* default_opt_level */ + -1 /* default hw_prefetchers_avail */ }; static const cpu_prefetch_tune thunderx2t99_prefetch_tune = @@ -578,7 +583,8 @@ static const cpu_prefetch_tune thunderx2t99_prefetch_tune = 32, /* l1_cache_size */ 64, /* l1_cache_line_size */ 256, /* l2_cache_size */ - -1 /* default_opt_level */ + -1, /* default_opt_level */ + -1 /* default hw_prefetchers_avail */ }; static const struct tune_params generic_tunings = -- 2.7.4 From patchwork Fri Sep 15 01:30:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 112668 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp70924qgf; Thu, 14 Sep 2017 18:30:49 -0700 (PDT) X-Received: by 10.84.224.199 with SMTP id k7mr26345773pln.403.1505439049315; Thu, 14 Sep 2017 18:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505439049; cv=none; d=google.com; s=arc-20160816; b=NzhLMI8eN3/UhJxoM1/gUEQmbNTNbA9kU8dnRXTRoX9Z7wTs3/dOYPvxNJACGBir5i AtoeYmUUvjl9ERfjL82gfJf9ovOhHKHGByK8n7W65QQBCdGY99VNTUt6031QBe3WbLGk u9dPilW40ojKEc+QTbvp1xS9qpMi9avv5Hogc8GfNw1eDPkI4pTn4c0drEydfaBz72Pk ijSRYHGqEwwnGml9ij0DYsg8sptfEe3wnhf/hRqN9SqwmTC1XcJMQqYHpSrp0ldL1JwY xSLDyi75UkAn2F9Bco1p1V/aniMhX5lyWq8JtD6/aTDUoAbqJxBqOd6uYYxNUeDpgGbx pymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=2t9v9NUTRPNW8gNLnS1SpA1itED2FS5KydZ6wSzazP8=; b=BaqXl1jopXUfdn04095iViRk0ujW5fV8GZUERScsYewAf5+ZnRZir30ZZZRrrytzXz fwJydc2m65tEUtAnpVIlu3Qr8Vc2Y/oBmUVWBIHfKKX2XisCHqHXLK3UyrKHIjVWffZQ ZVrwha54kOfzkhUhUcMTYYnk5rGs/h8EeupnTsjUd42m9zymFa9oRIMCbk7KJAOWvFIu bcILrYkdyVluph4TcyylwoUHUHNdfveIZxAlfTBLyeGYPWOiHLHBgPfwP462PlUn8Nc2 WLrXTt5ZRY2QAvpzaDT6SO9xuGXdN+Kc42oZqnHktX5V39rqarfiCBiOZaLXX/yPtZ++ j4SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tjnWleSM; spf=pass (google.com: domain of gcc-patches-return-462191-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462191-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 k5si1093552plt.762.2017.09.14.18.30.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 18:30:49 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462191-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=tjnWleSM; spf=pass (google.com: domain of gcc-patches-return-462191-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462191-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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=iAS0Uup5jR1Kkc6igTsX+0u1gAJyPQftrCRRxmmsaWCHgL 7EF5K2V0MkVp4Xsc6On4WTTnGl+zVjnBTvdX9k4YHFnUkiR+jUD5BXq4gBluMxLV Q4Nv2Q4+D15mV9nMH9o0rbrhrH+3i9q6VnjijwyPVJpWI0o1C03qunWEiPwjE= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=3lnh/Z4V+SKia1Eh/ZpkA4kPzhI=; b=tjnWleSMEAV8I9Jh2e/0 ZN4ZiSHtk/mHLYSQ4Hi0qZsna9RbBpRqFqGdTh4hGk7vs0JMMDMQxytRueeOjtK8 fTHYJqYyVcPBDrn0KIumW+5qVsiy8iWyd0XpW0mgvuspniNcqbItehniH0xLN9gZ SSnGOLVK6/2dAqbhvqVZw9g= Received: (qmail 111920 invoked by alias); 15 Sep 2017 01:30:36 -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 111882 invoked by uid 89); 15 Sep 2017 01:30:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f175.google.com Received: from mail-qt0-f175.google.com (HELO mail-qt0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 01:30:25 +0000 Received: by mail-qt0-f175.google.com with SMTP id l25so975881qtf.13 for ; Thu, 14 Sep 2017 18:30:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lH0+0BUjguHxQYt8KNrvUrkghtMFvqo6sYYuiD9xmKE=; b=BYxJrAt7TqAuptuN9ZElAWijzLcQVxwazZOW5vd+0aWKXtD/sLPFdzFoC7v98ZUfz0 lKbo4tJUy0YxcDnbyorLzcyRPhpg8VTQB8k7Mf/hH6F3v/FZBIYGn41IZfmfe4wZsBU9 eMMZPeHWF9+JXaLZd2ng/fOIE9vnOQV4K1l2KkFc0nRVNPx/RgbCkpgYqnjAEvzyJGAW suQUjQWrYUTnZcwruzaJpa1zU28WM+yGL+Yao5JF59SBr2zqVgPlYXEkKWpkUdWQYB+Y oidHa6+ypsQyQzJ/zp8oGCS7qno3jwXzZ3vp+YkT2LGdG2yqV6isGzdMtwsYgpv4IB6+ 12Mw== X-Gm-Message-State: AHPjjUiWz3uFtA9xV1cnK/iWdHUt4RUa4pHTJX7heGZ3lEl2HPDdTqVI jDlr7mUyCmRe4otS1UeTKuSg8AwcLCJ0yBzvTPeZDIuCrAI= X-Google-Smtp-Source: AOwi7QCyjYb9NjCsA2a1X8P0UQRKDXtXDr+ja+wAjAxOYvSmhhzU99Zx0L1AvguE3Oaa1mHspscklxgjPpBC72GhsB4= X-Received: by 10.237.35.35 with SMTP id h32mr32149413qtc.47.1505439016050; Thu, 14 Sep 2017 18:30:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.37.211 with HTTP; Thu, 14 Sep 2017 18:30:15 -0700 (PDT) From: Kugan Vivekanandarajah Date: Fri, 15 Sep 2017 11:30:15 +1000 Message-ID: Subject: [RFC][PACH 3/5] Prevent tree unroller from completely unrolling inner loops if that results in excessive strided-loads in outer loop To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes This patch prevent tree unroller from completely unrolling inner loops if that results in excessive strided-loads in outer loop. Thanks, Kugan gcc/ChangeLog: 2017-09-12 Kugan Vivekanandarajah * config/aarch64/aarch64.c (count_mem_load_streams): New. (aarch64_ok_to_unroll): New. * doc/tm.texi (ok_to_unroll): Define new target hook. * doc/tm.texi.in (ok_to_unroll): Likewise. * target.def (ok_to_unroll): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Use ok_to_unroll while unrolling. >From 5de245bbf6ba1768e8206a61feb0f42c106a1d94 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 18 Aug 2017 16:41:13 +1000 Subject: [PATCH 3/5] tree unroller limit strided loads --- gcc/config/aarch64/aarch64.c | 70 ++++++++++++++++++++++++++++++++++++++++++++ gcc/doc/tm.texi | 4 +++ gcc/doc/tm.texi.in | 2 ++ gcc/target.def | 8 +++++ gcc/tree-ssa-loop-ivcanon.c | 8 +++++ 5 files changed, 92 insertions(+) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 7d1ee70..e88bb6c 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -64,6 +64,7 @@ #include "sched-int.h" #include "target-globals.h" #include "common/common-target.h" +#include "tree-scalar-evolution.h" #include "selftest.h" #include "selftest-rtl.h" @@ -15122,6 +15123,72 @@ aarch64_sched_can_speculate_insn (rtx_insn *insn) } } +/* Count the strided loads in the LOOP with respect to OUT_LOOP. + If the strided loads are larger (compared to MAX_STRIDED_LOADS), + we dont need to compute all of them. */ + +static unsigned +count_mem_load_streams (struct loop *out_loop, + struct loop *loop, + unsigned max_strided_loads) +{ + basic_block *bbs = get_loop_body (loop); + unsigned nbbs = loop->num_nodes; + gimple_stmt_iterator gsi; + unsigned count = 0; + + for (unsigned i = 0; i < nbbs; i++) + { + bool ok; + basic_block bb = bbs[i]; + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + if (!is_gimple_assign (stmt) + || !gimple_vuse (stmt)) + continue; + tree op = gimple_assign_rhs1 (stmt); + if (!INDIRECT_REF_P (op) + && TREE_CODE (op) != MEM_REF + && TREE_CODE (op) != TARGET_MEM_REF) + continue; + op = TREE_OPERAND (op, 0); + tree ev = analyze_scalar_evolution (out_loop, op); + ev = instantiate_parameters (loop, ev); + if (no_evolution_in_loop_p (ev, out_loop->num, &ok) && !ok) + count++; + if (count >= max_strided_loads) + return count; + } + } + return count; +} + +/* Target hook that prevents complete loop unrolling if this would make + the outer loop's prefetch strems more than hardware can handle. */ + +static bool +aarch64_ok_to_unroll (struct loop *loop, unsigned HOST_WIDE_INT nunroll) +{ + struct loop *loop_father; + unsigned loads; + unsigned outter_loads; + + if (aarch64_tune_params.prefetch->hw_prefetchers_avail == -1) + return true; + + if ((loop_father = loop_outer (loop))) + { + unsigned max_strided_loads = aarch64_tune_params.prefetch->hw_prefetchers_avail; + loads = count_mem_load_streams (loop_father, loop, max_strided_loads); + outter_loads = count_mem_load_streams (loop_father, loop_father, max_strided_loads); + if ((outter_loads + (nunroll - 1) * loads) > max_strided_loads) + return false; + } + return true; +} + /* Target-specific selftests. */ #if CHECKING_P @@ -15550,6 +15617,9 @@ aarch64_libgcc_floating_mode_supported_p #undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS #define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 4 +#undef TARGET_OK_TO_UNROLL +#define TARGET_OK_TO_UNROLL aarch64_ok_to_unroll + #if CHECKING_P #undef TARGET_RUN_TARGET_SELFTESTS #define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 795e492..45cea4c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11617,6 +11617,10 @@ is required only when the target has special constraints like maximum number of memory accesses. @end deftypefn +@deftypefn {Target Hook} bool TARGET_OK_TO_UNROLL (struct loop *@var{loop_info}, unsigned HOST_WIDE_INT @var{nunroll}) +This hook should return false if target prefers loop should not be unrolled +@end deftypefn + @defmac POWI_MAX_MULTS If defined, this macro is interpreted as a signed integer C expression that specifies the maximum number of floating point multiplications diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 98f2e6b..64dfa51 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -8155,6 +8155,8 @@ build_type_attribute_variant (@var{mdecl}, @hook TARGET_LOOP_UNROLL_ADJUST +@hook TARGET_OK_TO_UNROLL + @defmac POWI_MAX_MULTS If defined, this macro is interpreted as a signed integer C expression that specifies the maximum number of floating point multiplications diff --git a/gcc/target.def b/gcc/target.def index bbd9c01..2f62328 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -5120,6 +5120,14 @@ hardware divmod insn but defines target-specific divmod libfuncs.", void, (rtx libfunc, machine_mode mode, rtx op0, rtx op1, rtx *quot, rtx *rem), NULL) +/* Target function to check complete unrolling of loop is profitable for loop. */ +DEFHOOK +(ok_to_unroll, + "This hook should return false if target prefers loop should not be unrolled", + bool, + (struct loop *loop_info, unsigned HOST_WIDE_INT nunroll), + NULL) + /* Return the class for a secondary reload, and fill in extra information. */ DEFHOOK (secondary_reload, diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index efb199a..c2016458 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "tree-cfgcleanup.h" #include "builtins.h" +#include "target.h" /* Specifies types of loops that may be unrolled. */ @@ -855,6 +856,13 @@ try_unroll_loop_completely (struct loop *loop, loop->num); return false; } + + if (targetm.ok_to_unroll + && !targetm.ok_to_unroll (loop, n_unroll)) + { + return false; + } + if (!n_unroll) dump_printf_loc (report_flags, locus, "loop turned into non-loop; it never loops.\n"); -- 2.7.4 From patchwork Fri Sep 15 01:31:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 112669 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp71874qgf; Thu, 14 Sep 2017 18:32:02 -0700 (PDT) X-Received: by 10.98.32.92 with SMTP id g89mr23083789pfg.285.1505439122695; Thu, 14 Sep 2017 18:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505439122; cv=none; d=google.com; s=arc-20160816; b=XA1mzKq88Z36CTVbxbEcg0FjKgpgLNp82+mMwqIju0ZHT6e7sOrlFUlSmJTlBv65lj BuuoWQibQ9hGHrt1H8zyqUCw9JiLELch4rBxdzGeTYfWu4h7KKSZlYo9s9rGpgElaY5G q04LADBWQP8ngBo8VsIKHgItOXs3uDwwASxxIsihdYjdjAY+gJaXn+EoLItef1X80DUq 9O6nyJvMKEHr5GO9be6XbI5JnWi2/zo7lOxIf5YVHrqWfC3B2guoLA1kwpiHvvXvRCc5 W0uMLHvO71wapokMNhuaULKyZTemtt+iXryeg31PuL05JwrXCT3/esE1rWcBtzauW9qi w1ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=TvoLuQ22btUofKk1Wiswx3rM2VGGwSf8HvNjU0iGHFA=; b=P/KRyzGbL1dI04eO2tlrUvku1HiOfQf6ys7MgcWA6dVQHxtbITgjbHcOBLZzhK8PXe Rq8EGOwDr4I9xt3ki1FRlJGIo9fgSWhQnP/ckhM822kTzrOiGlxxWxfpjjvsdf8nkd5C /Cs81CRxGANmx4xLREWtjATcdQ0AfTDhnrxfOmLEjhjokHs3xtztJPMs31SgbKQkGe6h aHJKe3Led/jCqLwj0Hh0Pu7ZShYC7QzMP1vFTvFDD7CLLsKvp63+WO6LwF0bU4T0Oxlb KBWBPNOc6oI9gkjyYsHuM8YcbYBpzqFGU/FIv8t/sAwMzxh6hxgU9AQ4C4r3RCbLw/Qm hqRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VLc2v3JT; spf=pass (google.com: domain of gcc-patches-return-462192-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462192-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 e1si13342932ple.320.2017.09.14.18.32.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 18:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462192-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=VLc2v3JT; spf=pass (google.com: domain of gcc-patches-return-462192-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462192-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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=jl+5N3uyRxllAgQ8VJWZWwzdq9rn14/CJDeNsua4ttVYPG siOrM08VdA65g104I5xWEF3tv/xSNUMihrUXGHdcDuDP0JzLwpazhoziozwE3xeu WjEE6H6jQKJ18Ejdw5juPu4GUS5XdNdyF11+bMThHcmxalr6sABhDboOs8eCE= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=uG0BpAt4I7lIuYDVo4ICo6wkQfk=; b=VLc2v3JTEFYKyg9TQpV1 6exyL4T1aqgxtXVtmbpy21jddBLD5YKdxtMVX+PpFLC5JvjTUmArJoutTaGA7VL9 rUwaeTdN2fhAVGrWVokIHgkAtWYy7nyH9up5Q1G41PPvuj0HIGX49Dj2qvJttDHL O06+slAAtl8jv46f/NLaWfA= Received: (qmail 113741 invoked by alias); 15 Sep 2017 01:31:48 -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 113728 invoked by uid 89); 15 Sep 2017 01:31:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f176.google.com Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 01:31:45 +0000 Received: by mail-qk0-f176.google.com with SMTP id u73so937232qkl.12 for ; Thu, 14 Sep 2017 18:31:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=pwJgCnFiTMOyq5E8lVO2MdpkyuBGDkKpIBeYP6JmDSE=; b=Kq4zR80YgzCpnp8cwAMbXzqImfIfNlygK5tGP/REC5btwnB/H6SUUJ/kx0SLHT3aNj inwL8q/OvUutkFGTYLjh8b7rHmYJFi9Ut/sjHAXmgYNRDUx8WDhXZYvMVqyQUXRp9RwR VFU9ie7R6K6FhuGQgEX/VtxN7G/aYzCc/YYWedE2jsgNywlkomMtxdkTQ4NU/Nd0wEBY ZLjn6jswxeI5jUD2Fpg4sHwSDGWs1PqmVkGo0SrhofjuaQp0O4ayJ0EBgot8LwzXustq Ce6caWM4EuueCzvIKrGhyMmuU1TQeyEU8QIuUT25DjwsTONjsqenDxSwA0B8XHanmnLv u0zg== X-Gm-Message-State: AHPjjUjOMH56lQW/ZtCM8b4e9brzfj+kQ3UDKCr5v27SNBG4EFWuGSKO K+g5ufLTdD7jDbmCIOQA7D3xGFn4bTRryvUQeAZ+VkU+D8Y= X-Google-Smtp-Source: AOwi7QCOqj7VCsRqgW+YYXlSFXZxfTI3WYFahWuyUFVJa9YeJr2mvdcOySoeaMDFpzZEBNnonbxn6K/FaTnwT+s82HI= X-Received: by 10.55.111.133 with SMTP id k127mr5668249qkc.182.1505439103766; Thu, 14 Sep 2017 18:31:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.37.211 with HTTP; Thu, 14 Sep 2017 18:31:43 -0700 (PDT) From: Kugan Vivekanandarajah Date: Fri, 15 Sep 2017 11:31:43 +1000 Message-ID: Subject: [RFC][PATCH 4/5] Change iv_analyze_result to take const_rtx. To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes Change iv_analyze_result to take const_rtx. This is just to make the next patch compile. No functional changes: Thanks, Kugan gcc/ChangeLog: 2017-09-12 Kugan Vivekanandarajah * cfgloop.h (iv_analyze_result): Change 2nd param from rtx to const_rtx. * df-core.c (df_find_def): Likewise. * df.h (df_find_def): Likewise. * loop-iv.c (iv_analyze_result): Likewise. >From 5d50c51c520d881104d44603514088a19e14e652 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 25 Aug 2017 10:49:50 +1000 Subject: [PATCH 4/5] Change iv_analyze_result to take const_rtx --- gcc/cfgloop.h | 2 +- gcc/df-core.c | 2 +- gcc/df.h | 2 +- gcc/loop-iv.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index e7ffa23..2308e7a 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -473,7 +473,7 @@ struct GTY(()) niter_desc extern void iv_analysis_loop_init (struct loop *); extern bool iv_analyze (rtx_insn *, rtx, struct rtx_iv *); -extern bool iv_analyze_result (rtx_insn *, rtx, struct rtx_iv *); +extern bool iv_analyze_result (rtx_insn *, const_rtx, struct rtx_iv *); extern bool iv_analyze_expr (rtx_insn *, rtx, machine_mode, struct rtx_iv *); extern rtx get_iv_value (struct rtx_iv *, rtx); diff --git a/gcc/df-core.c b/gcc/df-core.c index 1e84d4d..ecb6b15 100644 --- a/gcc/df-core.c +++ b/gcc/df-core.c @@ -1951,7 +1951,7 @@ df_bb_regno_last_def_find (basic_block bb, unsigned int regno) DF is the dataflow object. */ df_ref -df_find_def (rtx_insn *insn, rtx reg) +df_find_def (rtx_insn *insn, const_rtx reg) { df_ref def; diff --git a/gcc/df.h b/gcc/df.h index 07fd334..8861cc9 100644 --- a/gcc/df.h +++ b/gcc/df.h @@ -979,7 +979,7 @@ extern void df_check_cfg_clean (void); #endif extern df_ref df_bb_regno_first_def_find (basic_block, unsigned int); extern df_ref df_bb_regno_last_def_find (basic_block, unsigned int); -extern df_ref df_find_def (rtx_insn *, rtx); +extern df_ref df_find_def (rtx_insn *, const_rtx); extern bool df_reg_defined (rtx_insn *, rtx); extern df_ref df_find_use (rtx_insn *, rtx); extern bool df_reg_used (rtx_insn *, rtx); diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index 896fe0b1..745b613 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -1198,7 +1198,7 @@ iv_analyze (rtx_insn *insn, rtx val, struct rtx_iv *iv) /* Analyzes definition of DEF in INSN and stores the result to IV. */ bool -iv_analyze_result (rtx_insn *insn, rtx def, struct rtx_iv *iv) +iv_analyze_result (rtx_insn *insn, const_rtx def, struct rtx_iv *iv) { df_ref adef; -- 2.7.4 From patchwork Fri Sep 15 01:33:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 112670 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp72953qgf; Thu, 14 Sep 2017 18:33:46 -0700 (PDT) X-Received: by 10.101.88.131 with SMTP id d3mr10209035pgu.209.1505439225967; Thu, 14 Sep 2017 18:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505439225; cv=none; d=google.com; s=arc-20160816; b=N588Ze3gzHKt308/kDHUPWtNE/uzos64j8pKK4vG2HaN9K6yfZlltJeii6bBPi4hSi Idde71K5ql5AZuJCc//V5B9xJhn9b0F7hWJ+uB+yibVcYdAux9nJbG1q71/upjaqMCRt mob77xFVwHO8v71XSvdPQkvA6h5Mkd4A2EgZORwaPK/s6AmY6EKsl0J9zvlqeMEICgt4 SI7RGchOjis7SZuFoz+HXYrSTHHNs3xGueegVII3lxL+hpxcq73wrxR6rbsfSMH55gOH 6e1HsDvcU6BU15gh1fjRGF8VGen5UTeEFe5xlXljcF7fF0JksAekb1xn7VBd440/v2Ha nsSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=UPKoBomRH9DpKoyyDXx1OccyzbaZXwsBuC1CczPaTl0=; b=osIujfxjcQEzE/mr7uKKnhYV2qhETaGnZuROcrsH7nJDu4sNu+WEDwRhE7mLFKs72B Iodn+01zpMoWAMgwGdKGSVX4cDCO8AD4hHt0uDVI/IungDjlc00oPgNPMCHlhPYb0etF RghGVk2aJOmtFIVNZ8S/YQ110VI32B232Sp/ZYCgwvBiUfdb79ILKTPiwJGyEHur7Sel s3K7ktSoP55wK9/21HxSljxEe2Fh6LpVKHYfSU+5XTf69mKDRcpJyqNUwWZZGIq3D4/i s3UkQIDgRP5lb+BDP29x1Sbzis+8AZB6IHWVE8uwq2G2NVsX8xik036qXQDCZtcMEWS1 L+Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kc7n4hK8; spf=pass (google.com: domain of gcc-patches-return-462193-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462193-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 m12si12985499pln.643.2017.09.14.18.33.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2017 18:33:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462193-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=kc7n4hK8; spf=pass (google.com: domain of gcc-patches-return-462193-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462193-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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=ZROEOgmFwtShwNz5R8YyHvd4FIXZkQxSzISUS3snyPTYAh fEwxENL8NgbfvDpYUfZ6aiaZ0DfejAi5tLu4ALqvMKMUgPNKsQXXZjkUibUHdOJH IH8oxBGjnxdeo1CdjqnNyr2izxha/373jHAxwuYSmYfD51u2kkjVPlCgh1rvs= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=S4uBgiqx1VMBhVx94dTvpPJog1Q=; b=kc7n4hK8I/DcRtZVtr/A Mv8AKJyppHsnxVZMkarv/w8XxCK88orUem39yvWMIEBh7O4uCVNC2FFMNjqx2WWZ 4Y3ScVSj6FRATv4c3pKjR1WDrakHXeMjwHAIAU0GxLyT8o1r59K3YcsCRNDnDh10 AwssMZMENdH3vtWn2PIdkf8= Received: (qmail 115753 invoked by alias); 15 Sep 2017 01:33:33 -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 115744 invoked by uid 89); 15 Sep 2017 01:33:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f175.google.com Received: from mail-qt0-f175.google.com (HELO mail-qt0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 01:33:31 +0000 Received: by mail-qt0-f175.google.com with SMTP id s18so1004889qta.3 for ; Thu, 14 Sep 2017 18:33:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4oL5zEPTSVijPy+W3ivPCfh4qXJ/CxbylyiQoEfU5tU=; b=JN4rtPQ+rGCO6O5QMCChXjtp+qSpYpHrSnyuCVdeMRP2IXG1Ay96vUMvHnlUh1hiow ygiviMoYylp+MX4qy8vtywCb0sAL6PGA15QmwbxvH9luRdcNRL+L/2iykywxquAoR2YY mUgmQacpcFZZB5DyN6zhe/LRp/6pS21H7El7rF5a7zjpp5GntLJXqc8V/gikNFst4Mp6 LMzte0/wzLWGmzD5xQjt8p4xq7Pbes8nE0Nzu3MD4IHzQCgdiZXJ/OwYvl3smS6B+2ko Mj2YPX49j1WL8Oc2fFazsLhtxLOtbaBGIauh5QFaEyN0z59P6q3wIzgB6+HvSnaGr3BN 0eIw== X-Gm-Message-State: AHPjjUgDmtZFvvKXlUtGlt6pg8675W7mDGGnEFVbfg5rYdwTOf7PFf7I Par5iQBNnFvIEgPIu/W9JBdf0hdpD2SuN9WqQWfhSqZXYv4= X-Google-Smtp-Source: AOwi7QCjHQKUrFQlK0aYsNBaOFwL4XdfUswt7geiML8Gif6gxUmrCxcJGUQlmrSrcWd9Fpo5CCiXEMONASg6dSw5lyE= X-Received: by 10.237.37.228 with SMTP id y33mr25193921qtc.79.1505439210034; Thu, 14 Sep 2017 18:33:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.37.211 with HTTP; Thu, 14 Sep 2017 18:33:28 -0700 (PDT) From: Kugan Vivekanandarajah Date: Fri, 15 Sep 2017 11:33:28 +1000 Message-ID: Subject: [RFC][AARCH64][PATCH 5/5] add aarch64_loop_unroll_adjust to limit partial unrolling in rtl based on strided-loads in loop To: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes This patch adds aarch64_loop_unroll_adjust to limit partial unrolling in rtl based on strided-loads in loop. Thanks, Kugan gcc/ChangeLog: 2017-09-12 Kugan Vivekanandarajah * cfgloop.h (iv_analyze_biv): export. * loop-iv.c: Likewise. * config/aarch64/aarch64.c (strided_load_p): New. (insn_has_strided_load): New. (count_strided_load_rtl): New. (aarch64_loop_unroll_adjust): New. >From 10e02b026784798fff6a3513dc11b1cffb1cf78a Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Wed, 23 Aug 2017 12:35:14 +1000 Subject: [PATCH 5/5] add aarch64_loop_unroll_adjust --- gcc/cfgloop.h | 1 + gcc/config/aarch64/aarch64.c | 136 +++++++++++++++++++++++++++++++++++++++++++ gcc/loop-iv.c | 2 +- 3 files changed, 138 insertions(+), 1 deletion(-) diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 2308e7a..a3876a2 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -479,6 +479,7 @@ extern bool iv_analyze_expr (rtx_insn *, rtx, machine_mode, extern rtx get_iv_value (struct rtx_iv *, rtx); extern bool biv_p (rtx_insn *, rtx); extern void find_simple_exit (struct loop *, struct niter_desc *); +extern bool iv_analyze_biv (rtx def, struct rtx_iv *iv); extern void iv_analysis_done (void); extern struct niter_desc *get_simple_loop_desc (struct loop *loop); diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index e88bb6c..624a996 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -15189,6 +15189,139 @@ aarch64_ok_to_unroll (struct loop *loop, unsigned HOST_WIDE_INT nunroll) return true; } +/* Return true if X is a strided load. */ + +static bool +strided_load_p (const_rtx x) +{ + struct rtx_iv iv; + rtx reg; + + if (!MEM_P (x)) + return false; + + reg = XEXP (x, 0); + if (REG_P (reg) + || UNARY_P (reg)) + { + if (!REG_P (reg)) + reg = XEXP (reg, 0); + if (REG_P (reg) + && iv_analyze_biv (reg, &iv)) + return true; + } + else if (BINARY_P (reg)) + { + rtx reg1, reg2; + reg1 = XEXP (reg, 0); + reg2 = XEXP (reg, 1); + if (REG_P (reg1) + && iv_analyze_biv (reg1, &iv)) + return true; + if (REG_P (reg2) + && iv_analyze_biv (reg2, &iv)) + return true; + } + return false; +} + + +/* Return true if X INSN is a strided load. */ + +static bool +insn_has_strided_load (rtx_insn *insn) +{ + subrtx_iterator::array_type array; + if (!INSN_P (insn) || recog_memoized (insn) < 0) + return false; + rtx pat = PATTERN (insn); + + switch (GET_CODE (pat)) + { + case PARALLEL: + { + for (int j = 0; j < XVECLEN (pat, 0); ++j) + { + rtx ex = XVECEXP (pat, 0, j); + FOR_EACH_SUBRTX (iter, array, ex, NONCONST) + { + const_rtx x = *iter; + if (GET_CODE (x) == SET + && strided_load_p (SET_SRC (x))) + return true; + } + } + } + break; + + case SET: + FOR_EACH_SUBRTX (iter, array, SET_SRC (pat), NONCONST) + { + const_rtx x = *iter; + if (strided_load_p (x)) + return true; + } + + default: + break; + } + return false; +} + +/* Count the strided loads in the LOOP. If the strided loads are larger + (compared to MAX_STRIDED_LOADS), we dont need to compute all of + them. This is used to limit the partial unrolling factor to avoid + prefetcher collision. */ + +static unsigned +count_strided_load_rtl (struct loop *loop, unsigned max_strided_loads) +{ + basic_block *bbs; + unsigned count = 0; + rtx_insn *insn; + iv_analysis_loop_init (loop); + bbs = get_loop_body (loop); + + for (unsigned i = 0; i < loop->num_nodes; ++i) + { + FOR_BB_INSNS (bbs[i], insn) + { + if (insn_has_strided_load (insn)) + count ++; + + if (count > (max_strided_loads / 2)) + { + free (bbs); + iv_analysis_done (); + return count; + } + } + } + free (bbs); + iv_analysis_done (); + return count; +} + +/* Target hook loop_unroll_adjust that limits partial loop unrolling + factor, if this would make the outer loop's prefetch streams more + than hardware can handle. */ + +static unsigned +aarch64_loop_unroll_adjust (unsigned n_unroll, struct loop *loop) +{ + int max_strided_loads; + max_strided_loads = aarch64_tune_params.prefetch->hw_prefetchers_avail; + + if (max_strided_loads == -1) + return n_unroll; + + unsigned count = count_strided_load_rtl (loop, max_strided_loads); + if (count > 0) + n_unroll = 1 << (floor_log2 (max_strided_loads/count)); + + return n_unroll; +} + /* Target-specific selftests. */ #if CHECKING_P @@ -15620,6 +15753,9 @@ aarch64_libgcc_floating_mode_supported_p #undef TARGET_OK_TO_UNROLL #define TARGET_OK_TO_UNROLL aarch64_ok_to_unroll +#undef TARGET_LOOP_UNROLL_ADJUST +#define TARGET_LOOP_UNROLL_ADJUST aarch64_loop_unroll_adjust + #if CHECKING_P #undef TARGET_RUN_TARGET_SELFTESTS #define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index 745b613..3a8c54e 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -852,7 +852,7 @@ record_biv (rtx def, struct rtx_iv *iv) /* Determines whether DEF is a biv and if so, stores its description to *IV. */ -static bool +bool iv_analyze_biv (rtx def, struct rtx_iv *iv) { rtx inner_step, outer_step; -- 2.7.4