From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19661 invoked by alias); 13 Oct 2011 13:30:25 -0000 Received: (qmail 19642 invoked by uid 22791); 13 Oct 2011 13:30:22 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Oct 2011 13:29:55 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9DDTsHo017361 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Oct 2011 09:29:54 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9DDTrjg012960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 13 Oct 2011 09:29:53 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p9DDTqdr011321; Thu, 13 Oct 2011 15:29:52 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p9DDTqCs011319; Thu, 13 Oct 2011 15:29:52 +0200 Date: Thu, 13 Oct 2011 13:52:00 -0000 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, Andrew Pinski Subject: [PATCH] Handle COND_EXPR/VEC_COND_EXPR in walk_stmt_load_store_addr_ops and ssa verification Message-ID: <20111013132952.GM2210@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg01123.txt.bz2 Hi! Andrew mentioned on IRC he found walk_stmt_load_store_addr_ops doesn't handle COND_EXPR weirdo first argument well, the following patch is an attempt to handle that. I've noticed similar spot in verify_ssa, though in that case I'm not sure about whether the change is so desirable, as it doesn't seem to handle SSA_NAMEs embedded in MEM_EXPRs, ARRAY_REFs etc. either. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Or just the gimple.c part? 2011-10-13 Jakub Jelinek * gimple.c (walk_stmt_load_store_addr_ops): Call visit_addr also on COND_EXPR/VEC_COND_EXPR comparison operands if they are ADDR_EXPRs. * tree-ssa.c (verify_ssa): For COND_EXPR/VEC_COND_EXPR count SSA_NAMEs in comparison operand as well. --- gcc/gimple.c.jj 2011-10-13 11:13:39.000000000 +0200 +++ gcc/gimple.c 2011-10-13 11:15:25.000000000 +0200 @@ -5313,9 +5313,24 @@ walk_stmt_load_store_addr_ops (gimple st || gimple_code (stmt) == GIMPLE_COND)) { for (i = 0; i < gimple_num_ops (stmt); ++i) - if (gimple_op (stmt, i) - && TREE_CODE (gimple_op (stmt, i)) == ADDR_EXPR) - ret |= visit_addr (stmt, TREE_OPERAND (gimple_op (stmt, i), 0), data); + { + tree op = gimple_op (stmt, i); + if (op == NULL_TREE) + ; + else if (TREE_CODE (op) == ADDR_EXPR) + ret |= visit_addr (stmt, TREE_OPERAND (op, 0), data); + /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison + tree with two operands. */ + else if (i == 1 && COMPARISON_CLASS_P (op)) + { + if (TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR) + ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 0), + 0), data); + if (TREE_CODE (TREE_OPERAND (op, 1)) == ADDR_EXPR) + ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 1), + 0), data); + } + } } else if (is_gimple_call (stmt)) { --- gcc/tree-ssa.c.jj 2011-10-07 10:03:28.000000000 +0200 +++ gcc/tree-ssa.c 2011-10-13 11:19:30.000000000 +0200 @@ -1069,14 +1069,27 @@ verify_ssa (bool check_modified_stmt) for (i = 0; i < gimple_num_ops (stmt); i++) { op = gimple_op (stmt, i); - if (op && TREE_CODE (op) == SSA_NAME && --count < 0) + if (op == NULL_TREE) + continue; + if (TREE_CODE (op) == SSA_NAME) + --count; + /* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison + tree with two operands. */ + else if (i == 1 && COMPARISON_CLASS_P (op)) { - error ("number of operands and imm-links don%'t agree" - " in statement"); - print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS); - goto err; + if (TREE_CODE (TREE_OPERAND (op, 0)) == SSA_NAME) + --count; + if (TREE_CODE (TREE_OPERAND (op, 1)) == SSA_NAME) + --count; } } + if (count < 0) + { + error ("number of operands and imm-links don%'t agree" + " in statement"); + print_gimple_stmt (stderr, stmt, 0, TDF_VOPS|TDF_MEMSYMS); + goto err; + } FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_USE|SSA_OP_VUSE) { Jakub