From patchwork Mon May 6 22:16:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 241804 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 3E4962C00EA for ; Tue, 7 May 2013 08:16:42 +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 :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=EAZhS1vko+A4k1WrOBzhGZFTSRsrcRp5hwdf/RFpE6gcQGN4X9owO pcUGuF2wYGgFy/pbQ5zGpi1ixnzo8fkjazYolgpjALZYzycoY8GQh5foXw+AGz7Q NvnFobcX1EOT+xUMEult48JJH0OWP4E2vympi9q4Ye35Tr9pOBArsU= 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 :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:content-transfer-encoding:mime-version; s=default; bh=AMAYF+3oNWO7m5UBbGNteH8QC4o=; b=Z7JaLH5YRO+zmBy8N1zkWJcrCsKI NBLDotFgIaHGUlKuDPZo6gy367Jwt/s+pZYW79jpomGZ3rp1h04LCfIoYYX+sj1k 08vaVIVPi5OSHpA2JT+CMFOGXQSLlmqzqSQhpYEYZQ2ZJnDI3GonD6xesee3xnlk qdFaRgQSYLQDpqk= Received: (qmail 6393 invoked by alias); 6 May 2013 22:16:36 -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 6374 invoked by uid 89); 6 May 2013 22:16:33 -0000 X-Spam-SWARE-Status: No, score=-5.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, TW_OV autolearn=ham version=3.3.1 Received: from e28smtp03.in.ibm.com (HELO e28smtp03.in.ibm.com) (122.248.162.3) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 06 May 2013 22:16:33 +0000 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 May 2013 03:41:50 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 May 2013 03:41:48 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id E045F394002D for ; Tue, 7 May 2013 03:46:25 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r46MGHqd3670290 for ; Tue, 7 May 2013 03:46:17 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r46MGOI9016492 for ; Tue, 7 May 2013 08:16:24 +1000 Received: from [9.76.19.62] (sig-9-76-19-62.mts.ibm.com [9.76.19.62]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r46MGL3Y016319; Tue, 7 May 2013 08:16:23 +1000 Message-ID: <1367878586.11638.72.camel@gnopaine> Subject: [PATCH] Fix SLSR conditional candidate bug with commuted operands From: Bill Schmidt To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org, richard.guenther@gmail.com, bergner@vnet.ibm.com Date: Mon, 06 May 2013 17:16:26 -0500 In-Reply-To: <20130506192506.GQ28963@tucnak.redhat.com> References: <1367786717.11638.58.camel@gnopaine> <20130506192506.GQ28963@tucnak.redhat.com> Mime-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13050622-3864-0000-0000-000008044C20 This fixes the following bug: On Mon, 2013-05-06 at 21:25 +0200, Jakub Jelinek wrote: > On Sun, May 05, 2013 at 03:45:17PM -0500, Bill Schmidt wrote: > > 2013-05-05 Bill Schmidt > > > > * gimple-ssa-strength-reduction.c (slsr_process_phi): Re-enable. > > (find_candidates_in_block): Re-enable slsr_process_phi. > > (create_phi_basis): Fix double counting of candidate adjustment. > > This broke gcc.dg/pr33017.c testcase on i?86/x86_64 -m32. > ./cc1 -O2 -ftree-vectorize -m32 -mno-sse pr33017.c > difference between r19862{6,7} is: > --- pr33017.s1 2013-05-06 21:22:03.786745422 +0200 > +++ pr33017.s2 2013-05-06 21:22:16.844673015 +0200 > @@ -32,9 +32,9 @@ foo: > movb $87, var.1373+2(%eax) > je .L10 > cmpl $3, %edx > - movb $87, var.1373+3(%eax) > + movb $87, var.1373+2(%eax,%eax) > jne .L11 > - movb $87, var.1373+4(%eax) > + movb $87, var.1373+2(%eax,%eax,2) > movl $3, %ebp > movl $61, 28(%esp) > .L3: > > Jakub > The pattern we seek for replacing a conditional candidate can be confused when a CAND_ADD with an index of 1 has its operands commuted in the analysis. (For x = y + z, we may record two CAND_ADDs, one for either ordering of the addends.) For a candidate with reversed addends in the analysis, don't attempt to find a hidden basis. Otherwise we make an invalid replacement later on. Verified this fixes the reported bug. Bootstrapped and tested on powerpc64-unknown-linux-gnu with no new regressions. Ok for trunk? Thanks, Bill 2013-05-06 Bill Schmidt * gimple-ssa-strength-reduction.c (find_phi_def): Don't record a phi def as possibly hiding a basis for a CAND_ADD whose operands have been commuted in the analysis. (alloc_cand_and_find_basis): Add parms to call to find_phi_def. Index: gcc/gimple-ssa-strength-reduction.c =================================================================== --- gcc/gimple-ssa-strength-reduction.c (revision 198627) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -413,15 +413,29 @@ 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. */ + 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. */ static cand_idx -find_phi_def (tree base) +find_phi_def (gimple gs, enum cand_kind kind, tree base, + double_int index, tree stride) { slsr_cand_t c; if (TREE_CODE (base) != SSA_NAME) return 0; + + /* Check for commutativity condition. */ + 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); @@ -565,7 +579,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 (base); + c->def_phi = find_phi_def (gs, kind, base, index, stride); c->dead_savings = savings; cand_vec.safe_push (c);