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: 989942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-488464-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UOXFF3Q/"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YGSRxE/F"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42jGpR71X2z9s8F for ; Sun, 28 Oct 2018 10:11:57 +1100 (AEDT) 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=of0zIVHYQtsQqrg6FNWXWVVSdls0Zp7WjGDMHeU8a8Ds8e 9IkisVHfExL/rSqPXXfxJ04q+OoK963sJcOb2DOlulORa/oPgs78VfnrXFTJfCLz 2eVtvIaoq4zBiN+qrEPOwcrntzY02G1SaQ3zk+u3oHMvo4wnlLNMtJthlpAs8= 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=UOXFF3Q/dY/gaePZfctv arqnVaLX+g/ocmTwOmTZPCFzJuaHU2adY+CvnrgluhNDXflR3kwdZiPpVvLk8LEG /UcNCWicS9di3yC1SX21GnudDBCNJFtwE+65aJK5k8DbELf5MaC7CuM9eJdLEk/R SmwAbz7YeSwyT98DEqKMCsI= 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