From patchwork Tue Aug 1 10:09:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 796153 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-459484-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="sNfyAXnj"; 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 3xMBrh4zLxz9tWN for ; Tue, 1 Aug 2017 20:09:56 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=xE9eyIIaZQ8NBNNUIDICmPKVtuETc84kyrHzDiN2BsE9jh32cFzig D76i7182uDZkAFPnrgzdUKKIbJ+lOxkjES0AMhAjLslX5ka2FPA4ptE0Ycr+++Jq xAGBBqgac6XimiEXd1+w/GyhldJro/7Delza1D0IN4V94TbcIRuVjA= 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:subject:message-id:mime-version:content-type; s= default; bh=QbnJeJ78Q5LcDFj2SONcSCQooKg=; b=sNfyAXnjcrTBLJeZMc3a H5DP0ODk0mP1MSreYC/AYuuoxY7bgMH70ImxM9q1GvQUYFZtHs1e8wPlszbE1Jdl /gud77KbIob8P0s9Ct0nWwEv1pWG/0YMdjApRHcU8P6V6Qz1a9Ti7dGFoiBJo6WT odSP1o9/1kNNvg+ea1/TWzQ= Received: (qmail 130407 invoked by alias); 1 Aug 2017 10:09: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 130391 invoked by uid 89); 1 Aug 2017 10:09:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:inverte, boo 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; Tue, 01 Aug 2017 10:09:45 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0C26C75025 for ; Tue, 1 Aug 2017 10:09:43 +0000 (UTC) Date: Tue, 1 Aug 2017 12:09:42 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] PRE TLC, improve fake exit edge placement Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 When working on PR81181 I ran into some things I wanted to clean up several times. First a few PRE cleanups done for the fix. Second, the fake exit edges we add for infinite loops happen to start from loop headers rather than latches which is somewhat confusing and making PRE dataflow order more confusing than it already is. The patch makes it originate from the source of the closing edge instead of from the destination. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2017-08-01 Richard Biener * tree-ssa-pre.c (print_pre_expr): Handle NULL expr. (compute_antic): Seed worklist with exit block predecessors. * cfganal.c (dfs_find_deadend): For a cycle return the source of the edge closing it. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 250725) +++ gcc/tree-ssa-pre.c (working copy) @@ -837,7 +840,7 @@ bitmap_set_and (bitmap_set_t dest, bitma } } -/* Subtract all values and expressions contained in ORIG from DEST. */ +/* Subtract all expressions contained in ORIG from DEST. */ static bitmap_set_t bitmap_set_subtract (bitmap_set_t dest, bitmap_set_t orig) @@ -859,7 +862,7 @@ bitmap_set_subtract (bitmap_set_t dest, return result; } -/* Subtract all the values in bitmap set B from bitmap set A. */ +/* Subtract all values in bitmap set B from bitmap set A. */ static void bitmap_set_subtract_values (bitmap_set_t a, bitmap_set_t b) @@ -987,6 +990,11 @@ bitmap_value_insert_into_set (bitmap_set static void print_pre_expr (FILE *outfile, const pre_expr expr) { + if (! expr) + { + fprintf (outfile, "NULL"); + return; + } switch (expr->kind) { case CONSTANT: @@ -2418,7 +2473,9 @@ compute_antic (void) inverted_post_order_compute (&postorder); auto_sbitmap worklist (last_basic_block_for_fn (cfun) + 1); - bitmap_ones (worklist); + bitmap_clear (worklist); + FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) + bitmap_set_bit (worklist, e->src->index); while (changed) { if (dump_file && (dump_flags & TDF_DETAILS)) Index: gcc/cfganal.c =================================================================== --- gcc/cfganal.c (revision 250725) +++ gcc/cfganal.c (working copy) @@ -737,23 +737,24 @@ post_order_compute (int *post_order, boo basic_block dfs_find_deadend (basic_block bb) { - bitmap visited = BITMAP_ALLOC (NULL); + auto_bitmap visited; + basic_block next = bb; for (;;) { - if (EDGE_COUNT (bb->succs) == 0 - || ! bitmap_set_bit (visited, bb->index)) - { - BITMAP_FREE (visited); - return bb; - } + if (EDGE_COUNT (next->succs) == 0) + return next; + if (! bitmap_set_bit (visited, next->index)) + return bb; + + bb = next; /* If we are in an analyzed cycle make sure to try exiting it. Note this is a heuristic only and expected to work when loop fixup is needed as well. */ if (! bb->loop_father || ! loop_outer (bb->loop_father)) - bb = EDGE_SUCC (bb, 0)->dest; + next = EDGE_SUCC (bb, 0)->dest; else { edge_iterator ei; @@ -761,7 +762,7 @@ dfs_find_deadend (basic_block bb) FOR_EACH_EDGE (e, ei, bb->succs) if (loop_exit_edge_p (bb->loop_father, e)) break; - bb = e ? e->dest : EDGE_SUCC (bb, 0)->dest; + next = e ? e->dest : EDGE_SUCC (bb, 0)->dest; } }