From patchwork Tue Jul 19 13:26:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 105475 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 95ABFB6F68 for ; Tue, 19 Jul 2011 23:26:54 +1000 (EST) Received: (qmail 29835 invoked by alias); 19 Jul 2011 13:26:52 -0000 Received: (qmail 29822 invoked by uid 22791); 19 Jul 2011 13:26:50 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_TM 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; Tue, 19 Jul 2011 13:26:17 +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 E4C508F903 for ; Tue, 19 Jul 2011 15:26:15 +0200 (CEST) Date: Tue, 19 Jul 2011 15:26:15 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove TRUTH_* from expansion, fix PR18908 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 This splits out the real fix for PR18908 from the previous patch which also adjusted integer_all_onesp. It also removes the no longer appearing TRUTH_* exprs from expansion (and STATEMENT_LIST while I'm there). Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2011-07-19 Richard Guenther * expr.c (expand_expr_real_2): Remove TRUTH_*_EXPR handling. (expand_expr_real_1): Remove TRUTH_*IF_EXPR and STATEMENT_LIST handling. PR middle-end/18908 * expr.c (expand_expr_real_2): Do not unnecessarily truncate the result of BIT_*_EXPR to bitfield precision. Index: gcc/expr.c =================================================================== --- gcc/expr.c (revision 176444) +++ gcc/expr.c (working copy) @@ -8054,26 +8054,8 @@ expand_expr_real_2 (sepops ops, rtx targ and (a bitwise1 b) bitwise2 b (etc) but that is probably not worth while. */ - /* BIT_AND_EXPR is for bitwise anding. TRUTH_AND_EXPR is for anding two - boolean values when we want in all cases to compute both of them. In - general it is fastest to do TRUTH_AND_EXPR by computing both operands - as actual zero-or-1 values and then bitwise anding. In cases where - there cannot be any side effects, better code would be made by - treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR; but the question is - how to recognize those cases. */ - - case TRUTH_AND_EXPR: - code = BIT_AND_EXPR; case BIT_AND_EXPR: - goto binop; - - case TRUTH_OR_EXPR: - code = BIT_IOR_EXPR; case BIT_IOR_EXPR: - goto binop; - - case TRUTH_XOR_EXPR: - code = BIT_XOR_EXPR; case BIT_XOR_EXPR: goto binop; @@ -8152,18 +8134,6 @@ expand_expr_real_2 (sepops ops, rtx targ emit_label (op1); return target; - case TRUTH_NOT_EXPR: - if (modifier == EXPAND_STACK_PARM) - target = 0; - op0 = expand_expr (treeop0, target, - VOIDmode, EXPAND_NORMAL); - /* The parser is careful to generate TRUTH_NOT_EXPR - only with operands that are always zero or one. */ - temp = expand_binop (mode, xor_optab, op0, const1_rtx, - target, 1, OPTAB_LIB_WIDEN); - gcc_assert (temp); - return temp; - case COMPLEX_EXPR: /* Get the rtx code of the operands. */ op0 = expand_normal (treeop0); @@ -8319,6 +8289,12 @@ expand_expr_real_2 (sepops ops, rtx targ temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp, OPTAB_LIB_WIDEN); gcc_assert (temp); + /* Bitwise operations do not need bitfield reduction as we expect their + operands being properly truncated. */ + if (code == BIT_XOR_EXPR + || code == BIT_AND_EXPR + || code == BIT_IOR_EXPR) + return temp; return REDUCE_BIT_FIELD (temp); } #undef REDUCE_BIT_FIELD @@ -9541,47 +9517,6 @@ expand_expr_real_1 (tree exp, rtx target return op0; - /* Use a compare and a jump for BLKmode comparisons, or for function - type comparisons is HAVE_canonicalize_funcptr_for_compare. */ - - /* Although TRUTH_{AND,OR}IF_EXPR aren't present in GIMPLE, they - are occassionally created by folding during expansion. */ - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - if (! ignore - && (target == 0 - || modifier == EXPAND_STACK_PARM - || ! safe_from_p (target, treeop0, 1) - || ! safe_from_p (target, treeop1, 1) - /* Make sure we don't have a hard reg (such as function's return - value) live across basic blocks, if not optimizing. */ - || (!optimize && REG_P (target) - && REGNO (target) < FIRST_PSEUDO_REGISTER))) - target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode); - - if (target) - emit_move_insn (target, const0_rtx); - - op1 = gen_label_rtx (); - jumpifnot_1 (code, treeop0, treeop1, op1, -1); - - if (target) - emit_move_insn (target, const1_rtx); - - emit_label (op1); - return ignore ? const0_rtx : target; - - case STATEMENT_LIST: - { - tree_stmt_iterator iter; - - gcc_assert (ignore); - - for (iter = tsi_start (exp); !tsi_end_p (iter); tsi_next (&iter)) - expand_expr (tsi_stmt (iter), const0_rtx, VOIDmode, modifier); - } - return const0_rtx; - case COND_EXPR: /* A COND_EXPR with its type being VOID_TYPE represents a conditional jump and is handled in