From patchwork Sat Oct 27 23:11:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 149608 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2414252ljp; Sat, 27 Oct 2018 16:12:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5f6ZNVf8Rzkiqq5e6Dhz6B0/lCE+19LQ82uCaZMEW1hXQvXcLmXogziQPutnwkOhIEY7vtb X-Received: by 2002:a63:2c8a:: with SMTP id s132-v6mr8302954pgs.73.1540681921625; Sat, 27 Oct 2018 16:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540681921; cv=none; d=google.com; s=arc-20160816; b=ZmRwqIcVybL45Iq5ZxsNsg2IBsyH80nUUO/FwFHQWZ1p5KIUZls0Ge0pd4ve8OMvqk 7zfTsZF9HF2/nNMg3VpOnIKHSoDx8azs8usnopfgapCoMv3UjRo1GHMuMNMCanFu7ox4 epeCjcQbFa4Zryu94PPBvl3gWR0QwJXc9cN2WD6URWGCotLmg0/8VnKfl5cSkZPms51N 3BsX/JNPC+skqUb6Wx7+Vjyfo4cfIbUA7eQbv7On5mSI9EN4BYwncLjMMo24jOs554fS FEYjqaYfm0BsRjOEGQMnPiFjCGGFjf2ZFFfDNnSntvdE6hADjsodQj9wFd/ITPACpY1S 9EqA== 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:dkim-signature :delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=Kw/G9atCXxjsD2aqnD+dGj/0PQyU5sqlwJvntvRS180=; b=JgyllynIzqsaR5jJ5Q/PqI8bd2k+WWWhiJGA0dg1CsExFyMGan/2BP9sAnR3ZMQSVL wOwCUkIc3TlI3Rr5Rc5QyX5fGWYvKHq+7QDaWl2SjGZWIQi2CmouK/hvKqEv+iw1ZOGk pvBd5tNTL+qN2q2mqLffYMzKaEXBBLKV5TuyxVTEPNjnvp/9/ZNTFSXTV3R117Z0MCdA xlHtSTUSDr52nWfZpZ/x/Q4eogrAHyRV3KsipX3vXOQtRvsMjmubV+iQ/qHvXmEUVT3V mX4TtDAGCAeg1b3NSVL7R9dwwDNCRk8gfukDmVHkTxiKbTYc5c00aqvNo3juwltu8++p b3nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="ySErm6y/"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="YGSRxE/F"; spf=pass (google.com: domain of gcc-patches-return-488464-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-488464-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 q10-v6si15690392pgk.392.2018.10.27.16.12.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 16:12:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-488464-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="ySErm6y/"; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="YGSRxE/F"; spf=pass (google.com: domain of gcc-patches-return-488464-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-488464-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=inOW8VGPRfnwGTdIDJNBzQFUWZXFT78t8zoa0TusGYWKnq Z5ZvizQwP38/Gp0i2c4Kgb5L/rmfEaOrfoyEdnSeShkfLr/EZXndPBbKyiEgD1EB lgKs5hmva919e1RfrdIzAIdkG53NUZY5WoGTMO1NbvE/K/5BnZe/c1ufiN49U= 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=hx31qSv6cPx3M7469zKdzF78GMk=; b=ySErm6y/hmPzjlCaM9HN KQ4CAxIpXMwas6gki26eTPS5onb9hF57KbqXKhG3WmvGFcN3/lpZYs9v2U4o+HmB hdHWdLEzNEZ5aco+pHGgukBl8Wn5F1wOjOzR1IbIdYviOZ38ginH3mLqZnD4OJZz x7XeYsZm1mK7CNf6fCuybKo= Received: (qmail 119550 invoked by alias); 27 Oct 2018 23:11:50 -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 119531 invoked by uid 89); 27 Oct 2018 23:11:49 -0000 Authentication-Results: sourceware.org; auth=none 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, SPF_PASS autolearn=ham version=3.3.2 spammy=kugan, sk:vivekan, sk:kuganv, Kugan X-HELO: mail-lf1-f44.google.com Received: from mail-lf1-f44.google.com (HELO mail-lf1-f44.google.com) (209.85.167.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 Oct 2018 23:11:47 +0000 Received: by mail-lf1-f44.google.com with SMTP id o2-v6so3417716lfl.13 for ; Sat, 27 Oct 2018 16:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:from:date:message-id:subject:to; bh=g6S/oRzccxb20FisUybzhCP2V225QXYgEqWlWNhbLFI=; b=YGSRxE/FtOEMTUY8oP1tU++c1pvsjp3miYGt9NxmuL5jvFU6ecRlf8h0c1EwM/k6My KkD7LRg1WMAbZBfKyJRwUsOFy/d2f+CCkwQrCMLoz/c7gxh70LJzPdzcKKRohKMEKzhs g04tBh0O+rrhR+oNBmi8DxdQqXEzXuDxwtTgw= MIME-Version: 1.0 From: Kugan Vivekanandarajah Date: Sun, 28 Oct 2018 10:11:08 +1100 Message-ID: Subject: [PR87469] ICE in record_estimate, at tree-ssa-loop-niter.c To: GCC Patches X-IsSubscribed: yes Hi, In the testcase provided in the bug report, max value for niter estimation is off by one when it is INTEGER_CST. As a results it asserts at the place where it is checked for equality. Attached patch fixes this. Bootstrapped and regression tested on x86_64-linux-gnu with no new regression. Is this OK? Thanks, Kugan gcc/testsuite/ChangeLog: 2018-10-26 Kugan Vivekanandarajah PR middle-end/87469 * g++.dg/pr87469.C: New test. gcc/ChangeLog: 2018-10-26 Kugan Vivekanandarajah PR middle-end/87469 * tree-ssa-loop-niter.c (number_of_iterations_popcount): Fix niter max value. >From 359f6aa2d603784b900feedb7ad450523695e191 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 26 Oct 2018 09:04:47 +1100 Subject: [PATCH] pr87469 V2 Change-Id: If1f7da7450ae27e24baf638861c97ff416f8484a --- gcc/testsuite/g++.dg/pr87469.C | 15 +++++++++++++++ gcc/tree-ssa-loop-niter.c | 8 +++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr87469.C diff --git a/gcc/testsuite/g++.dg/pr87469.C b/gcc/testsuite/g++.dg/pr87469.C new file mode 100644 index 0000000..2f6de97 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr87469.C @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-c -w -O2" } */ +long a; +struct c { + void d(unsigned f) { + long e = f; + while (e & (e - 1)) + e &= e - 1; + a = e; + } +}; +void g() { + c b; + b.d(4 + 2); +} diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index e2bc936..e763b35 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2589,11 +2589,9 @@ number_of_iterations_popcount (loop_p loop, edge exit, if (TREE_CODE (call) == INTEGER_CST) max = tree_to_uhwi (call); else - { - max = TYPE_PRECISION (TREE_TYPE (src)); - if (adjust) - max = max - 1; - } + max = TYPE_PRECISION (TREE_TYPE (src)); + if (adjust) + max = max - 1; niter->niter = iter; niter->assumptions = boolean_true_node; -- 2.7.4