From patchwork Fri Aug 12 11:02:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 658590 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 3s9hmn5RNVz9ryk for ; Fri, 12 Aug 2016 21:02:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=R4p7kX/Y; 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=MHfPRrQd9B+Eu+dTYBrwfVib7vqZMqTG080gfgtPJdFuwTUea3n8z S96LvOsDwcSx3phB8IbEGDFGh0ej+uB/AzWOYCodXo4zfVeKiMKeON8hHS0o1cBh bDSiaJEKnL9lBjlE5wo4TCv11ofJsNewqRpR32U/JTLanugAxvxqWo= 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=WszSC2HTjPklJVlJN05Ke/GTmxg=; b=R4p7kX/YKtjGPAyl+Xkv tb1uFAOk8ACbavOp0MY5MuA+S/Sy3lpiivRSEPmcJyoE43UvtqntIZQXjUCe7+Zj duoOMA3GdVvFf1kehEn1h7M9tEHzC/DPnv/titfwcZiIvgxNk+xoaK9SiFwx0LZl 0pC55bh2YIPiMNqS15o9UEs= Received: (qmail 19261 invoked by alias); 12 Aug 2016 11:02:25 -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 19233 invoked by uid 89); 12 Aug 2016 11:02:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=BAYES_20, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=*fun, gsi_next, gsi_start_bb, gsi_end_p X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Aug 2016 11:02:13 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 34C0DACFD for ; Fri, 12 Aug 2016 11:02:11 +0000 (UTC) Date: Fri, 12 Aug 2016 13:02:11 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Properly propagate into PHIs in forwprop Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 forwprop has a lattice now (mainly for match-and-simplify simplification) but it fails to substitute into PHIs or update the lattice for degenerate PHIs. Fixed thusly. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2016-08-12 Richard Biener * tree-ssa-forwprop.c (pass_forwprop::execute): Propagate into PHIs and update the lattice for its def. Index: gcc/tree-ssa-forwprop.c =================================================================== --- gcc/tree-ssa-forwprop.c (revision 239406) +++ gcc/tree-ssa-forwprop.c (working copy) @@ -2107,6 +2107,35 @@ pass_forwprop::execute (function *fun) gimple_stmt_iterator gsi; basic_block bb = BASIC_BLOCK_FOR_FN (fun, postorder[i]); + /* Propagate into PHIs and record degenerate ones in the lattice. */ + for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si); + gsi_next (&si)) + { + gphi *phi = si.phi (); + tree res = gimple_phi_result (phi); + if (virtual_operand_p (res)) + continue; + + use_operand_p use_p; + ssa_op_iter it; + tree first = NULL_TREE; + bool all_same = true; + FOR_EACH_PHI_ARG (use_p, phi, it, SSA_OP_USE) + { + tree use = USE_FROM_PTR (use_p); + tree tem = fwprop_ssa_val (use); + if (! first) + first = tem; + else if (! operand_equal_p (first, tem, 0)) + all_same = false; + if (tem != use + && may_propagate_copy (use, tem)) + propagate_value (use_p, tem); + } + if (all_same) + fwprop_set_lattice_val (res, first); + } + /* Apply forward propagation to all stmts in the basic-block. Note we update GSI within the loop as necessary. */ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )