From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17557 invoked by alias); 18 Mar 2013 10:29:14 -0000 Received: (qmail 17528 invoked by uid 22791); 18 Mar 2013 10:29:13 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,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; Mon, 18 Mar 2013 10:29:07 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 51F76A51F6 for ; Mon, 18 Mar 2013 11:29:06 +0100 (CET) Date: Mon, 18 Mar 2013 10:29:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR56483 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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: 2013-03/txt/msg00642.txt.bz2 This fixes PR56483 by properly testing for boolean values during expansion of conditionals. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2013-03-18 Richard Biener PR middle-end/56483 * cfgexpand.c (expand_gimple_cond): Inline gimple_cond_single_var_p and implement properly. * gimple.h (gimple_cond_single_var_p): Remove. Index: gcc/cfgexpand.c =================================================================== *** gcc/cfgexpand.c (revision 196309) --- gcc/cfgexpand.c (working copy) *************** expand_gimple_cond (basic_block bb, gimp *** 1886,1894 **** be cleaned up by combine. But some pattern matchers like if-conversion work better when there's only one compare, so make up for this here as special exception if TER would have made the same change. */ ! if (gimple_cond_single_var_p (stmt) ! && SA.values && TREE_CODE (op0) == SSA_NAME && bitmap_bit_p (SA.values, SSA_NAME_VERSION (op0))) { gimple second = SSA_NAME_DEF_STMT (op0); --- 1886,1899 ---- be cleaned up by combine. But some pattern matchers like if-conversion work better when there's only one compare, so make up for this here as special exception if TER would have made the same change. */ ! if (SA.values && TREE_CODE (op0) == SSA_NAME + && TREE_CODE (TREE_TYPE (op0)) == BOOLEAN_TYPE + && TREE_CODE (op1) == INTEGER_CST + && ((gimple_cond_code (stmt) == NE_EXPR + && integer_zerop (op1)) + || (gimple_cond_code (stmt) == EQ_EXPR + && integer_onep (op1))) && bitmap_bit_p (SA.values, SSA_NAME_VERSION (op0))) { gimple second = SSA_NAME_DEF_STMT (op0); Index: gcc/gimple.h =================================================================== *** gcc/gimple.h (revision 196309) --- gcc/gimple.h (working copy) *************** gimple_cond_false_p (const_gimple gs) *** 2747,2769 **** return false; } - /* Check if conditional statement GS is of the form 'if (var != 0)' or - 'if (var == 1)' */ - - static inline bool - gimple_cond_single_var_p (gimple gs) - { - if (gimple_cond_code (gs) == NE_EXPR - && gimple_cond_rhs (gs) == boolean_false_node) - return true; - - if (gimple_cond_code (gs) == EQ_EXPR - && gimple_cond_rhs (gs) == boolean_true_node) - return true; - - return false; - } - /* Set the code, LHS and RHS of GIMPLE_COND STMT from CODE, LHS and RHS. */ static inline void --- 2747,2752 ----