From patchwork Wed Apr 19 13:55:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 752293 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3w7NnG5F7jz9ryv for ; Wed, 19 Apr 2017 23:55:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="RCgm0s74"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=MeGu6HIoYYCo0BFs1oW95xSOXGg6E ClCNPJ3CR+Cd+7+FVsbOdMU9pjzcpVStIVD2vxix1As6EofUPtyV5oLBrYFELfCf 1yYwA3UcByjWOkSQ+8F/I2IfJbuAxuPutOSxHvEL/H1uCowt2dtwqNqhMfJaX9wU Gpw21AWHwQdVmo= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=XwtZjygDkXv7FO0hQ6XQWBA6dOk=; b=RCg m0s74Hu51qljY3D27c3/fPbfpAJ2UTZ05W8RMqTaRCHDp5WfyhUoQ9Y3lSz9PzN/ o7bCT0Zq3Cv39GzYuEk7DfL6t3TmsWYV9RKan4PbJsWjZF4SFR3LdHKxOZSFUvY7 I8ngy3tAN7yoH8+hseRKNO9mqA4tGmFN1g41Fias= Received: (qmail 39955 invoked by alias); 19 Apr 2017 13:55:28 -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 39588 invoked by uid 89); 19 Apr 2017 13:55:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Apr 2017 13:55:25 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DA584E4CA; Wed, 19 Apr 2017 13:55:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DA584E4CA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9DA584E4CA Received: from tucnak.zalov.cz (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 418207EE88; Wed, 19 Apr 2017 13:55:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v3JDtLMi007604; Wed, 19 Apr 2017 15:55:22 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v3JDtKqa007603; Wed, 19 Apr 2017 15:55:20 +0200 Date: Wed, 19 Apr 2017 15:55:19 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -fcompare-debug bugs during updating into loop closed ssa form (PR debug/80436) Message-ID: <20170419135519.GG1809@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi! -fcompare-debug fails on the following testcase, because during loop splitting we attempt to switch into loop closed SSA form and use also debug stmt uses in those decisions, which is wrong. Looking at the rest of tree-ssa-loop-manip.c, both find_uses_to_rename_stmt and check_loop_closed_ssa_stmt ignore debug stmts, this patch just adds that to another spot. Without it a new SSA_NAME is created (only with -g) and then soon (in the next pass) removed again because DCE sees it as dead (it has no non-debug uses) and is replaced by the definition from the loop again. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2017-04-19 Jakub Jelinek PR debug/80436 * tree-ssa-loop-manip.c (find_uses_to_rename_def): Ignore debug uses. * g++.dg/opt/pr80436.C: New test. Jakub --- gcc/tree-ssa-loop-manip.c.jj 2017-02-27 15:19:12.000000000 +0100 +++ gcc/tree-ssa-loop-manip.c 2017-04-19 09:47:30.768610273 +0200 @@ -494,6 +494,9 @@ find_uses_to_rename_def (tree def, bitma FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def) { + if (is_gimple_debug (use_stmt)) + continue; + basic_block use_bb = gimple_bb (use_stmt); use_operand_p use_p; --- gcc/testsuite/g++.dg/opt/pr80436.C.jj 2017-04-19 09:54:59.370714079 +0200 +++ gcc/testsuite/g++.dg/opt/pr80436.C 2017-04-19 09:56:28.003549930 +0200 @@ -0,0 +1,42 @@ +// PR debug/80436 +// { dg-do compile { target c++11 } } +// { dg-options "-O3 -fcompare-debug" } + +void fn (...); +void foo (int, int, int); +struct { int elt1; int bits; } *a; +int b, d; + +int +bar (unsigned *x) +{ + if (0) + next_bit: + return 1; + while (1) + { + if (b) + if (a->bits) + goto next_bit; + *x = b; + if (a->elt1) + return 0; + a = 0; + } +} + +enum { C0, C1 } *c; + +void +baz () +{ + int e, m = d; + for (; e < m; e++) + { + if (e < 0) + foo (0, 0, c[e]); + unsigned f; + for (; bar (&f);) + fn (f); + } +}