From patchwork Tue May 7 18:12:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 242433 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 7523E2C017D for ; Wed, 8 May 2013 04:12:38 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:content-type:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=OSCCnb5IMdt/TnKe IL0/Sy5BOBnvIkbSO1Dhx5oOYqay6tb7NzwbBesH31Ivb30Ml1TRgqgE8eeFsF0n pEziSYDR6aVHMjY5JZuCvbalcr4kUenP4O3/GPl+NfaWocqbD5ONQLEI5tqoVoSU U4H/Q3MfOPFlMYIcGYr/2h7w2pw= 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 :subject:from:to:cc:content-type:date:message-id:mime-version :content-transfer-encoding; s=default; bh=w6xB/5A3DBjXq1eDaq7Z9A fGD7w=; b=PYN3UbEIy7F9AYOihEpH1JS2flBb2NhtqKi1iFRzA1ioyYZYrDEADQ HVRHnIWgxhjEw6GKG0JsFeBT0SBy5lt0KWrB9Ye7UisoADftFkRB5rmxewOCaAMn sUdsEd/dCKDcxglNZ8lu4+0VXiVEy94aiX2wMOPK33mtzNJxea8Lo= Received: (qmail 32240 invoked by alias); 7 May 2013 18:12:32 -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 32229 invoked by uid 89); 7 May 2013 18:12:31 -0000 X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, MAY_BE_FORGED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from e9.ny.us.ibm.com (HELO e9.ny.us.ibm.com) (32.97.182.139) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 07 May 2013 18:12:30 +0000 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 May 2013 14:12:28 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 May 2013 14:12:27 -0400 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 5559838C8045 for ; Tue, 7 May 2013 14:12:26 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r47ICQCk298578 for ; Tue, 7 May 2013 14:12:26 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r47ICQPo002679 for ; Tue, 7 May 2013 14:12:26 -0400 Received: from [9.10.86.97] (oc8801110288.ibm.com.rchland.ibm.com [9.10.86.97] (may be forged)) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r47ICPMR002489; Tue, 7 May 2013 14:12:25 -0400 Subject: [PATCH] Restrict conditional SLSR candidates to CAND_MULTs From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, bergner@vnet.ibm.com, jakub@redhat.com, hjl.tools@gmail.com Date: Tue, 07 May 2013 13:12:23 -0500 Message-ID: <1367950343.4938.34.camel@oc8801110288.ibm.com> Mime-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050718-7182-0000-0000-000006951A1E The intent of conditional candidate processing in SLSR was always to apply it only to CAND_MULT candidates [(base + index) * stride]. However, I neglected to actually enforce this, leading to wrong code generated for CAND_ADD candidates. This patch adds the restriction. My previous "fix" wasn't sufficient; at the time I thought we were handling CAND_ADD candidates improperly, when in reality we shouldn't have been handling them at all. So this patch also backs out that change, which becomes dead code with the CAND_MULT restriction. I've verified this fixes the pr33017.c and vect-28.c tests. I haven't yet reproduced the remaining Fortran problems, but I am hopeful that this will fix those as well. If you see these have been fixed, please let me know; otherwise I will work on reproducing them. Bootstrapped and tested on powerpc64-unknown-linux-gnu, -m32/-m64, with no new regressions. Ok for trunk? Thanks, Bill 2013-05-07 Bill Schmidt * gimple-ssa-strength-reduction.c (find_phi_def): Revert former "fix." (alloc_cand_and_find_basis): Restrict conditional candidate processing to CAND_MULTs. Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 198682) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -415,32 +415,16 @@ cand_chain_hasher::equal (const value_type *chain1 static hash_table base_cand_map; /* Look in the candidate table for a CAND_PHI that defines BASE and - return it if found; otherwise return NULL. GS is the candidate - statement with BASE, INDEX, and STRIDE. If GS is a CAND_ADD with - an index of 1 and an SSA name for STRIDE, we must be careful that - we haven't commuted the operands for this candidate. STRIDE must - correspond to the second addend of GS for the eventual transformation - to be legal. If not, return NULL. */ + return it if found; otherwise return NULL. */ static cand_idx -find_phi_def (gimple gs, enum cand_kind kind, tree base, - double_int index, tree stride) +find_phi_def (tree base) { slsr_cand_t c; if (TREE_CODE (base) != SSA_NAME) return 0; - /* If we've commuted the operands (so "y + z" is represented as - "z + (1 * y)"), we don't have the pattern we're looking for. - Bail out to avoid doing a wrong replacement downstream. */ - if (kind == CAND_ADD - && index.is_one () - && TREE_CODE (stride) == SSA_NAME - && gimple_assign_rhs_code (gs) == PLUS_EXPR - && stride != gimple_assign_rhs2 (gs)) - return 0; - c = base_cand_from_table (base); if (!c || c->kind != CAND_PHI) @@ -583,7 +567,7 @@ alloc_cand_and_find_basis (enum cand_kind kind, gi c->next_interp = 0; c->dependent = 0; c->sibling = 0; - c->def_phi = find_phi_def (gs, kind, base, index, stride); + c->def_phi = kind == CAND_MULT ? find_phi_def (base) : 0; c->dead_savings = savings; cand_vec.safe_push (c);