From patchwork Thu Jul 21 18:04:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 106122 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 A6FDFB6EE8 for ; Fri, 22 Jul 2011 04:05:26 +1000 (EST) Received: (qmail 7595 invoked by alias); 21 Jul 2011 18:05:25 -0000 Received: (qmail 7587 invoked by uid 22791); 21 Jul 2011 18:05:24 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e37.co.us.ibm.com (HELO e37.co.us.ibm.com) (32.97.110.158) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jul 2011 18:05:05 +0000 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6LI1su3006962 for ; Thu, 21 Jul 2011 12:01:54 -0600 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6LI4sSr140734 for ; Thu, 21 Jul 2011 12:04:55 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6LIAQQJ005312 for ; Thu, 21 Jul 2011 12:10:26 -0600 Received: from [9.10.86.28] (9-10-86-28.rchland.ibm.com [9.10.86.28]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6LIAQb9004560 for ; Thu, 21 Jul 2011 12:10:26 -0600 Subject: [PATCH, pre-approved] Fix operand scan problems for PR49749 From: "William J. Schmidt" To: gcc-patches@gcc.gnu.org Date: Thu, 21 Jul 2011 13:04:47 -0500 Message-ID: <1311271487.5308.7.camel@oc2474580526.ibm.com> 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 This patch fixes part of PR tree-optimization/49749. The operand scans in tree-ssa-reassoc.c:get_rank() can be prematurely halted by two erroneous conditions, which this patch removes. Patch pre-approved by IRC communication with Richard Guenther, 7/21/11. The wider issue of biasing reassociation in favor of loop-carried dependencies is still pending. Bootstrapped and regression-tested on powerpc64-linux. I'll commit it shortly. 2011-07-21 Bill Schmidt PR tree-optimization/49749 * tree-ssa-reassoc.c (get_rank): Fix operand scan conditions and remove no-longer-used maxrank variable. Index: gcc/tree-ssa-reassoc.c =================================================================== --- gcc/tree-ssa-reassoc.c (revision 176569) +++ gcc/tree-ssa-reassoc.c (working copy) @@ -235,7 +235,7 @@ get_rank (tree e) if (TREE_CODE (e) == SSA_NAME) { gimple stmt; - long rank, maxrank; + long rank; int i, n; if (TREE_CODE (SSA_NAME_VAR (e)) == PARM_DECL @@ -258,7 +258,6 @@ get_rank (tree e) /* Otherwise, find the maximum rank for the operands, or the bb rank, whichever is less. */ rank = 0; - maxrank = bb_rank[gimple_bb(stmt)->index]; if (gimple_assign_single_p (stmt)) { tree rhs = gimple_assign_rhs1 (stmt); @@ -267,15 +266,15 @@ get_rank (tree e) rank = MAX (rank, get_rank (rhs)); else { - for (i = 0; - i < n && TREE_OPERAND (rhs, i) && rank != maxrank; i++) - rank = MAX(rank, get_rank (TREE_OPERAND (rhs, i))); + for (i = 0; i < n; i++) + if (TREE_OPERAND (rhs, i)) + rank = MAX(rank, get_rank (TREE_OPERAND (rhs, i))); } } else { n = gimple_num_ops (stmt); - for (i = 1; i < n && rank != maxrank; i++) + for (i = 1; i < n; i++) { gcc_assert (gimple_op (stmt, i)); rank = MAX(rank, get_rank (gimple_op (stmt, i)));