From patchwork Fri Sep 9 09:35:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 114033 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]) by ozlabs.org (Postfix) with SMTP id 42B31B6FF5 for ; Fri, 9 Sep 2011 19:35:33 +1000 (EST) Received: (qmail 14485 invoked by alias); 9 Sep 2011 09:35:30 -0000 Received: (qmail 14343 invoked by uid 22791); 9 Sep 2011 09:35:29 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 09 Sep 2011 09:35:15 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id DFF4C89994 for ; Fri, 9 Sep 2011 11:35:13 +0200 (CEST) Date: Fri, 9 Sep 2011 11:35:13 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix swap_tree_operands Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 swap_tree_operands does not handle swapping operands in a_1 = x_2 + 1; very well as it keeps the use operand for x_2 pointing to its old slot and thus 1 after it finished. That's of course bad as no user of swap_tree_operands feels the need to update the statement - swap_tree_operands is after all exactly to avoid updating the statement (and eventually disrupting the operand list). Fixed, thus. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2011-09-09 Richard Guenther * tree-ssa-operands.c (swap_tree_operands): Always adjust existing operand positions. Index: gcc/tree-ssa-operands.c =================================================================== --- gcc/tree-ssa-operands.c (revision 178719) +++ gcc/tree-ssa-operands.c (working copy) @@ -1149,7 +1149,8 @@ swap_tree_operands (gimple stmt, tree *e /* If the operand cache is active, attempt to preserve the relative positions of these two operands in their respective immediate use - lists. */ + lists by adjusting their use pointer to point to the new + operand position. */ if (ssa_operands_active () && op0 != op1) { use_optype_p use0, use1, ptr; @@ -1170,14 +1171,12 @@ swap_tree_operands (gimple stmt, tree *e break; } - /* If both uses don't have operand entries, there isn't much we can do - at this point. Presumably we don't need to worry about it. */ - if (use0 && use1) - { - tree *tmp = USE_OP_PTR (use1)->use; - USE_OP_PTR (use1)->use = USE_OP_PTR (use0)->use; - USE_OP_PTR (use0)->use = tmp; - } + /* And adjust their location to point to the new position of the + operand. */ + if (use0) + USE_OP_PTR (use0)->use = exp1; + if (use1) + USE_OP_PTR (use1)->use = exp0; } /* Now swap the data. */