From patchwork Mon Jun 3 08:12:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1109119 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-502170-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LeBRdbjJ"; 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 45HSTt333Fz9s1c for ; Mon, 3 Jun 2019 18:12:42 +1000 (AEST) 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:mime-version:content-type; q=dns; s=default; b=tF7VgKoOHUbmR78LJ9rqp00Ktcl1cnNSXbKZQo7W2piSKfQl4D qpl2A75eSEneEO1Y+7S5D/KYq5hWf09cUs52CNe8UMOhtfbTe6eWNELA2gTnTDAF 3tulZC8rnm9MWoFfsjGyG5wW1Fa6l148f2MDIuO/INWH6JGCXMKrH6de4= 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:mime-version:content-type; s= default; bh=uNiUphOQYO1o+h+GEuU++noPiOk=; b=LeBRdbjJX+Z5MorRe76R F63TfEV1H8l6TeJWoHCMOD2lEzLxpveEv+7JKkp1IG5kbMDF4EbEPWgLSayYA2MC JZ+uNw3LgtkVYi3n7gUkkVWMb4j0xXhDcsrR4KneQCDUJJiS13juk/eWczux4BN8 yy4WrQht3GAxn6NTLfkD5Qk= Received: (qmail 54045 invoked by alias); 3 Jun 2019 08:12:35 -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 54031 invoked by uid 89); 3 Jun 2019 08:12:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.1 spammy=bare, ssa, SSA, dangling X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jun 2019 08:12:33 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 20C16B150; Mon, 3 Jun 2019 08:12:31 +0000 (UTC) Date: Mon, 3 Jun 2019 10:12:30 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: aoliva@redhat.com Subject: [PATCH] Fix PR90716, wrong-debug with loop-distribution Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Loop removal was processing blocks in the wrong order, reversing debug stmt execution order between blocks (but having correct order within a block). Bootstrap & regtest running on x86_64-unknown-linux-gnu. The testcase exposes PR90717 and thus currently FAILs with -flto -fuse-linker-plugin. We seem to lack a dg-xfail-if and dg-xfail-run-if isn't applicable here. Anyhow, hope that Alex can fix this issue. Richard. 2019-06-03 Richard Biener PR tree-optimization/90716 * tree-loop-distribution.c (destroy_loop): Process blocks in correct order. * gcc.dg/guality/pr90716.c: New testcase. Index: gcc/tree-loop-distribution.c =================================================================== --- gcc/tree-loop-distribution.c (revision 271803) +++ gcc/tree-loop-distribution.c (working copy) @@ -1104,15 +1104,13 @@ destroy_loop (struct loop *loop) gimple_stmt_iterator dst_gsi = gsi_after_labels (exit->dest); bool safe_p = single_pred_p (exit->dest); - i = nbbs; - do + for (unsigned i = 0; i < nbbs; ++i) { /* We have made sure to not leave any dangling uses of SSA names defined in the loop. With the exception of virtuals. Make sure we replace all uses of virtual defs that will remain outside of the loop with the bare symbol as delete_basic_block will release them. */ - --i; for (gphi_iterator gsi = gsi_start_phis (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) { @@ -1147,7 +1145,6 @@ destroy_loop (struct loop *loop) gsi_next (&gsi); } } - while (i != 0); redirect_edge_pred (exit, src); exit->flags &= ~(EDGE_TRUE_VALUE|EDGE_FALSE_VALUE); Index: gcc/testsuite/gcc.dg/guality/pr90716.c =================================================================== --- gcc/testsuite/gcc.dg/guality/pr90716.c (nonexistent) +++ gcc/testsuite/gcc.dg/guality/pr90716.c (working copy) @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +void __attribute__((noinline)) +optimize_me_not () +{ + __asm__ volatile ("" : : : "memory"); +} +int a[7][8]; +int main() +{ + int b, j; + b = 0; + for (; b < 7; b++) { + j = 0; + for (; j < 8; j++) + a[b][j] = 0; + } + /* j may very well be optimized out, so we cannot test for j == 8. + Instead test j + 1 which will make the test UNSUPPORTED if i + is optimized out. Since the test previously had wrong debug + with j == 0 this is acceptable. */ + optimize_me_not(); /* { dg-final { gdb-test . "j + 1" "9" } } */ + return 0; +}