From patchwork Thu Apr 20 14:21:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 752828 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 3w81JJ1wr5z9ryT for ; Fri, 21 Apr 2017 00:21:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YD/xYeud"; 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=sJs9fWCwSJ0HCBzaQMvd9z2t/Q3+V1J2SLinmqDApovDRpCMBfdSH MmYtoRF19dvRfvuqQtyDKOf5pvHMfC9omZ3m0jjiufd378Wp601Kij2O3iLRQNb2 PjROQK9jsMvgo2hz/45TOYTuWjgBLc/CPZCrvs0wx3oWTSmEaXjChY= 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=ASmcS7yEoLwo8lgJyLcx3Xc32Gw=; b=YD/xYeuddQedBA0ffkbl rqlgjvEA2ItA9tN/ewsQbXEmHu23PmX1se8zTzQV5zQBNCvV0Hj9D12x/9a7n1LK 3nRJ8K/AIpJ/pzfsAr286/a4WVt4U0tKZLRepaXHUmUju9NaDV7xmgjclCE20Vpp E6WqpeOeSOJPrmTjnuWBUZQ= Received: (qmail 98350 invoked by alias); 20 Apr 2017 14:21:09 -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 98326 invoked by uid 89); 20 Apr 2017 14:21:08 -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= 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; Thu, 20 Apr 2017 14:21:06 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 72E5BAB9D for ; Thu, 20 Apr 2017 14:21:06 +0000 (UTC) Date: Thu, 20 Apr 2017 16:21:06 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR80453 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes PR80453. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk sofar. Richard. 2017-04-20 Richard Biener PR tree-optimization/80453 * tree-ssa-sccvn.h (struct vn_phi_s): Add cclhs and ccrhs members. * tree-ssa-sccvn.c (cond_stmts_equal_p): Use recorded lhs and rhs from the conditions. (vn_phi_eq): Pass them down. (vn_phi_lookup): Record them. (vn_phi_insert): Likewise. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 246964) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -2916,14 +2916,11 @@ vn_phi_compute_hash (vn_phi_t vp1) the other. */ static bool -cond_stmts_equal_p (gcond *cond1, gcond *cond2, bool *inverted_p) +cond_stmts_equal_p (gcond *cond1, tree lhs1, tree rhs1, + gcond *cond2, tree lhs2, tree rhs2, bool *inverted_p) { enum tree_code code1 = gimple_cond_code (cond1); enum tree_code code2 = gimple_cond_code (cond2); - tree lhs1 = gimple_cond_lhs (cond1); - tree lhs2 = gimple_cond_lhs (cond2); - tree rhs1 = gimple_cond_rhs (cond1); - tree rhs2 = gimple_cond_rhs (cond2); *inverted_p = false; if (code1 == code2) @@ -2941,10 +2938,6 @@ cond_stmts_equal_p (gcond *cond1, gcond else return false; - lhs1 = vn_valueize (lhs1); - rhs1 = vn_valueize (rhs1); - lhs2 = vn_valueize (lhs2); - rhs2 = vn_valueize (rhs2); return ((expressions_equal_p (lhs1, lhs2) && expressions_equal_p (rhs1, rhs2)) || (commutative_tree_code (code1) @@ -3002,7 +2995,10 @@ vn_phi_eq (const_vn_phi_t const vp1, con return false; bool inverted_p; if (! cond_stmts_equal_p (as_a (last1), - as_a (last2), &inverted_p)) + vp1->cclhs, vp1->ccrhs, + as_a (last2), + vp2->cclhs, vp2->ccrhs, + &inverted_p)) return false; /* Get at true/false controlled edges into the PHI. */ @@ -3081,6 +3077,16 @@ vn_phi_lookup (gimple *phi) vp1.type = TREE_TYPE (gimple_phi_result (phi)); vp1.phiargs = shared_lookup_phiargs; vp1.block = gimple_bb (phi); + /* Extract values of the controlling condition. */ + vp1.cclhs = NULL_TREE; + vp1.ccrhs = NULL_TREE; + basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1.block); + if (EDGE_COUNT (idom1->succs) == 2) + if (gcond *last1 = dyn_cast (last_stmt (idom1))) + { + vp1.cclhs = vn_valueize (gimple_cond_lhs (last1)); + vp1.ccrhs = vn_valueize (gimple_cond_rhs (last1)); + } vp1.hashcode = vn_phi_compute_hash (&vp1); slot = current_info->phis->find_slot_with_hash (&vp1, vp1.hashcode, NO_INSERT); @@ -3117,6 +3123,16 @@ vn_phi_insert (gimple *phi, tree result) vp1->type = TREE_TYPE (gimple_phi_result (phi)); vp1->phiargs = args; vp1->block = gimple_bb (phi); + /* Extract values of the controlling condition. */ + vp1->cclhs = NULL_TREE; + vp1->ccrhs = NULL_TREE; + basic_block idom1 = get_immediate_dominator (CDI_DOMINATORS, vp1->block); + if (EDGE_COUNT (idom1->succs) == 2) + if (gcond *last1 = dyn_cast (last_stmt (idom1))) + { + vp1->cclhs = vn_valueize (gimple_cond_lhs (last1)); + vp1->ccrhs = vn_valueize (gimple_cond_rhs (last1)); + } vp1->result = result; vp1->hashcode = vn_phi_compute_hash (vp1); Index: gcc/tree-ssa-sccvn.h =================================================================== --- gcc/tree-ssa-sccvn.h (revision 246964) +++ gcc/tree-ssa-sccvn.h (working copy) @@ -67,6 +67,9 @@ typedef struct vn_phi_s hashval_t hashcode; vec phiargs; basic_block block; + /* Controlling condition lhs/rhs. */ + tree cclhs; + tree ccrhs; tree type; tree result; } *vn_phi_t;