From patchwork Thu Oct 6 09:28:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 117985 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 4D3F3B6F9B for ; Thu, 6 Oct 2011 20:28:39 +1100 (EST) Received: (qmail 4633 invoked by alias); 6 Oct 2011 09:28:35 -0000 Received: (qmail 4619 invoked by uid 22791); 6 Oct 2011 09:28:33 -0000 X-SWARE-Spam-Status: No, hits=-7.2 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 mx3-phx2.redhat.com (HELO mx3-phx2.redhat.com) (209.132.183.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 06 Oct 2011 09:28:15 +0000 Received: from mail06.corp.redhat.com (zmail06.collab.prod.int.phx2.redhat.com [10.5.5.45]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p969SEPk008825; Thu, 6 Oct 2011 05:28:14 -0400 Date: Thu, 06 Oct 2011 05:28:14 -0400 (EDT) From: Kai Tietz To: gcc-patches@gcc.gnu.org Cc: Richard Guenther , Richard Henderson Subject: Re: [patch tree-optimization]: Improve handling of conditional-branches on targets with high branch costs Message-ID: <27f38089-c8cb-430c-8b3f-843df092d7db@zmail06.collab.prod.int.phx2.redhat.com> In-Reply-To: <503a466e-2de1-4e7b-a8bb-819d5d1f155c@zmail06.collab.prod.int.phx2.redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 Hello, Sorry attached non-updated change. Here with proper attached patch. This patch improves in fold_truth_andor the generation of branch-conditions for targets having LOGICAL_OP_NON_SHORT_CIRCUIT set. If right-hand side operation of a TRUTH_(OR|AND)IF_EXPR is simple operand, has no side-effects, and doesn't trap, then try to convert expression to a TRUTH_(AND|OR)_EXPR, if left-hand operand is a simple operand, and has no side-effects. ChangeLog 2011-10-06 Kai Tietz * fold-const.c (fold_truth_andor): Convert TRUTH_(AND|OR)IF_EXPR to TRUTH_OR_EXPR, if suitable. Bootstrapped and tested for all languages (including Ada and Obj-C++) on host x86_64-unknown-linux-gnu. Ok for apply? Regards, Kai ndex: fold-const.c =================================================================== --- fold-const.c (revision 179592) +++ fold-const.c (working copy) @@ -8387,6 +8387,33 @@ if ((tem = fold_truthop (loc, code, type, arg0, arg1)) != 0) return tem; + if ((code == TRUTH_ANDIF_EXPR || code == TRUTH_ORIF_EXPR) + && !TREE_SIDE_EFFECTS (arg1) + && simple_operand_p (arg1) + && LOGICAL_OP_NON_SHORT_CIRCUIT + && !FLOAT_TYPE_P (TREE_TYPE (arg1)) + && ((TREE_CODE_CLASS (TREE_CODE (arg1)) != tcc_comparison + && TREE_CODE (arg1) != TRUTH_NOT_EXPR) + || !FLOAT_TYPE_P (TREE_TYPE (TREE_OPERAND (arg1, 0))))) + { + if (TREE_CODE (arg0) == code + && !TREE_SIDE_EFFECTS (TREE_OPERAND (arg0, 1)) + && simple_operand_p (TREE_OPERAND (arg0, 1))) + { + tem = build2_loc (loc, + (code == TRUTH_ANDIF_EXPR ? TRUTH_AND_EXPR + : TRUTH_OR_EXPR), + type, TREE_OPERAND (arg0, 1), arg1); + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem); + } + if (!TREE_SIDE_EFFECTS (arg0) + && simple_operand_p (arg0)) + return build2_loc (loc, + (code == TRUTH_ANDIF_EXPR ? TRUTH_AND_EXPR + : TRUTH_OR_EXPR), + type, arg0, arg1); + } + return NULL_TREE; }