From patchwork Thu Jan 11 12:49:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Cheng X-Patchwork-Id: 859097 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-470828-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="x2XpF1NT"; 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 3zHQhG0Z3sz9ryr for ; Thu, 11 Jan 2018 23:50:04 +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:from :to:cc:subject:date:message-id:content-type:mime-version; q=dns; s=default; b=OmDMskoH3irWnLv+rnS0p1VtYNuqHf6EH9vzCLdBfSX5NqRTEl S9bsFUp9Dd4TO6WoCZLXajagIGgS299tZPIvycaKujYqSrG8jfVJuN0SAfDXv4UL cyfwXIAmrYB8//uxfvpu64i9nE7qVISoF1rvqwZgWtH5H5PR8ho9V2iZs= 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:content-type:mime-version; s= default; bh=sP1Qd9lQoeyBKzgwd61VAsJ+5yk=; b=x2XpF1NTAEDZF51CWoqu WSqWDJ81XoXYlttETdaSHSj+VaQ/g+ESv75cjXK7hBLXpXcMmDEXglecp0/cyPd4 8vDWUaKaZcsjy1s/j/9wxUsPIuO/pB3oUbj7atlHdTszdwSZ4OsePD3+dBp6T5J8 8Vo8QTgWVYqfxQtrWfHNqGY= Received: (qmail 50369 invoked by alias); 11 Jan 2018 12:49:57 -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 50295 invoked by uid 89); 11 Jan 2018 12:49:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:interch, H*c:HHH X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0043.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Jan 2018 12:49:54 +0000 Received: from DB5PR0801MB2742.eurprd08.prod.outlook.com (10.166.176.26) by DB5PR0801MB2741.eurprd08.prod.outlook.com (10.166.176.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 11 Jan 2018 12:49:49 +0000 Received: from DB5PR0801MB2742.eurprd08.prod.outlook.com ([10.166.176.26]) by DB5PR0801MB2742.eurprd08.prod.outlook.com ([10.166.176.26]) with mapi id 15.20.0386.006; Thu, 11 Jan 2018 12:49:48 +0000 From: Bin Cheng To: "gcc-patches@gcc.gnu.org" CC: nd Subject: [PATCH PR83695]Fix ICE by resetting cached scev info after interchange. Date: Thu, 11 Jan 2018 12:49:48 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bin.Cheng@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5PR0801MB2741; 7:SBt49x2olFWomhEpsQNMoo0SQklEpCaYGHS67T+iEuzy1OmCQHFMV9cYIrp+nFiKobkjje6E2unpvphLZ1W9bK8AGdm6pGs+C7CJZSBuonwlAiwlEKJmI/zNh56oBA4ffPDW3GQ5YwBxn9tJ6TvU8IGzbFXswgzrLXGzCyFGTA5KiBQmRyx13Qy+5fCpYaY3W5f3dUVKfFxhAqCe2K7OtPSfzZrtvlKpvqkH1TOE8XWZIOzs2S2IULBruZdLDflP x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e4a26861-a088-4e11-32ca-08d558f1ccba x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(49563074)(7193020); SRVR:DB5PR0801MB2741; x-ms-traffictypediagnostic: DB5PR0801MB2741: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041268)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:DB5PR0801MB2741; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DB5PR0801MB2741; x-forefront-prvs: 0549E6FD50 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(39860400002)(396003)(376002)(366004)(199004)(189003)(377424004)(2900100001)(5640700003)(99936001)(7736002)(5660300001)(99286004)(33656002)(81156014)(74316002)(2351001)(106356001)(316002)(305945005)(105586002)(68736007)(8936002)(97736004)(8676002)(81166006)(7696005)(2906002)(478600001)(102836004)(6116002)(72206003)(3846002)(6506007)(3660700001)(66066001)(86362001)(3280700002)(6916009)(25786009)(53936002)(9686003)(4326008)(6436002)(77096006)(2501003)(14454004)(55016002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR0801MB2741; H:DB5PR0801MB2742.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Fde8HrQJyDzGZhajVTK6d2RvG5sV3MIrRH3S0nw3ROp2aUH1vU0rCXNdZlyf1qm4fb8+SDC726m6rZIx/XbJ5Q== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4a26861-a088-4e11-32ca-08d558f1ccba X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2018 12:49:48.6973 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR0801MB2741 X-IsSubscribed: yes Hi, As explained in comment of PR83695, outdated cached scev info could be referred by later interchange of outer loops in nest. This simple patch fixes ICE by resetting cached scev info after interchange. It's expensive resetting all scev information but might not be a problem here given we only interchange in limited cases. Bootstrap and test on x86_64 and AArch64. Is it OK? Thanks, bin 2018-01-11 Bin Cheng PR tree-optimization/83695 * gimple-loop-linterchange.cc (tree_loop_interchange::interchange_loops): Call scev_reset_htab to reset cached scev information after interchange. (pass_linterchange::execute): Remove call to scev_reset_htab. gcc/testsuite 2018-01-11 Bin Cheng PR tree-optimization/83695 * gcc.dg/tree-ssa/pr83695.c: New test. diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc index 01a26c0..eb35263 100644 --- a/gcc/gimple-loop-interchange.cc +++ b/gcc/gimple-loop-interchange.cc @@ -1119,6 +1119,10 @@ tree_loop_interchange::interchange_loops (loop_cand &iloop, loop_cand &oloop) oloop.m_loop->any_likely_upper_bound = false; free_numbers_of_iterations_estimates (oloop.m_loop); + /* Clear all cached scev information. This is expensive but shouldn't be + a problem given we interchange in very limited times. */ + scev_reset_htab (); + /* ??? The association between the loop data structure and the CFG changed, so what was loop N at the source level is now loop M. We should think of retaining the association or breaking @@ -2070,9 +2074,6 @@ pass_linterchange::execute (function *fun) loop_nest.release (); } - if (changed_p) - scev_reset_htab (); - return changed_p ? (TODO_update_ssa_only_virtuals) : 0; } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr83695.c b/gcc/testsuite/gcc.dg/tree-ssa/pr83695.c new file mode 100644 index 0000000..af56a31 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr83695.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a[3][3][3], b, d; +short c; +unsigned char e; + +static void f () +{ + for (c = 0; c < 2; c++) + for (e = 0; e < 3; e++) + for (b = 0; b < 3; b++) + a[b][e][b] = 0; + while (1) + ; +} + +int main () +{ + if (d) + f (); + return 0; +}