From patchwork Sat Nov 23 01:15:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1199737 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514455-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tstjw0tu"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="PXsWTtZc"; 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 47Kb303qV4z9sPT for ; Sat, 23 Nov 2019 12:15:54 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=UL0 oTFYDZf2qgBo9M+NSR0LlgXpQfGkW7jJfdnmMzplmgKATO8JONloOsIkNekfrmZM 7LMTbs4y3q+kp7FlTnYFOFiyhZDYUDPMvOnmKyalcIPxoAQUwHstRnjfJ4DztNvz bpHiH3LbhXxS4+azNAQ+oa1xbuKk2nEVILCemrZI= 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:content-transfer-encoding; s=default; bh=NUXk7X3K3 h2ZxxvS1346CCOcN7A=; b=tstjw0tuy4YEG7MZt9NrSvQi3KRsd/7XOHEzIqR/i ZHUpg+RO3wIoxWn6LHG6+TGRIzTO9WARGWSOJENtkYjOWdXxQc78wOc7eOL7XLii c2ipZjJym9VfibnRWzYzsW2kKx5Oq4S9uk8B6G7KfCeNv7jO7h9U7M6hd+WFNLzA P4= Received: (qmail 59773 invoked by alias); 23 Nov 2019 01:15:47 -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 59764 invoked by uid 89); 23 Nov 2019 01:15:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=HTo:U*ebotcazou X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Nov 2019 01:15:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574471744; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=f8pTXUAHugLbrk4k/nwI6B5uY3oN1oMhdl/A/XDu+G8=; b=PXsWTtZcJMlWmhZpM3vubL+X8R3wvSEvfXpSt0niHzWrsFwE4rL3Nq0ZAIuE8FyFtC1Yce sIvdknjZVJA/W03qowybtcLZaBosZMhWk+Fqssm7aq4rYevU8o8o6ZOfUJl3on7BrbehvP NsnIgdzrqQ5TOW4CKSegYJyATDchlac= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-G051TAzXNwu8bHWCgMV04Q-1; Fri, 22 Nov 2019 20:15:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FF818024C2; Sat, 23 Nov 2019 01:15:41 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C1D210013A1; Sat, 23 Nov 2019 01:15:40 +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 xAN1Fcfw015796; Sat, 23 Nov 2019 02:15:38 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xAN1FaRx015795; Sat, 23 Nov 2019 02:15:36 +0100 Date: Sat, 23 Nov 2019 02:15:36 +0100 From: Jakub Jelinek To: Jeff Law , Richard Biener , Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Perform cfg cleanup in cse if needed (PR rtl-optimization/92610) Message-ID: <20191123011536.GI2466@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! cse_main which sets tem has: if (cse_jumps_altered || recorded_label_ref) return 2; else if (cse_cfg_altered) return 1; else return 0; at the end, but after these two functions call it, they call also delete_trivially_dead_insns. Even when cse_main didn't need cfg changes, delete_trivially_dead_insns could remove a trivially dead insn that had EH edges and so we might still need to remove unreachable blocks. The following patch implements it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-23 Jakub Jelinek PR rtl-optimization/92610 * cse.c (rest_of_handle_cse2): Call cleanup_cfg (0) also if cse_cfg_altered is set, even when tem is 0. (rest_of_handle_cse_after_global_opts): Likewise. * g++.dg/opt/pr92610.C: New test. Jakub --- gcc/cse.c.jj 2019-11-19 22:27:01.960059340 +0100 +++ gcc/cse.c 2019-11-22 15:51:34.639806155 +0100 @@ -7701,7 +7701,7 @@ rest_of_handle_cse2 (void) cse_cfg_altered |= cleanup_cfg (CLEANUP_CFG_CHANGED); timevar_pop (TV_JUMP); } - else if (tem == 1) + else if (tem == 1 || cse_cfg_altered) cse_cfg_altered |= cleanup_cfg (0); cse_not_expected = 1; @@ -7775,7 +7775,7 @@ rest_of_handle_cse_after_global_opts (vo cse_cfg_altered |= cleanup_cfg (CLEANUP_CFG_CHANGED); timevar_pop (TV_JUMP); } - else if (tem == 1) + else if (tem == 1 || cse_cfg_altered) cse_cfg_altered |= cleanup_cfg (0); flag_cse_follow_jumps = save_cfj; --- gcc/testsuite/g++.dg/opt/pr92610.C.jj 2019-11-22 15:52:46.254734331 +0100 +++ gcc/testsuite/g++.dg/opt/pr92610.C 2019-11-22 15:53:14.991303498 +0100 @@ -0,0 +1,13 @@ +// PR rtl-optimization/92610 +// { dg-do compile } +// { dg-options "-w -fdelete-dead-exceptions --param=sccvn-max-alias-queries-per-access=0 -fno-dse -fnon-call-exceptions -Os -funroll-loops -ftrapv" } + +struct C { int x; ~C () {} }; + +int +main () +{ + C *buffer = new C[42]; + buffer[-3].x = 42; + delete [] buffer; +}