From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26151 invoked by alias); 8 Mar 2004 19:51:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 26138 invoked by uid 48); 8 Mar 2004 19:51:21 -0000 Date: Mon, 08 Mar 2004 19:51:00 -0000 Message-ID: <20040308195121.26137.qmail@sources.redhat.com> From: "kazu at cs dot umass dot edu" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040308164756.14483.kazu@cs.umass.edu> References: <20040308164756.14483.kazu@cs.umass.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug optimization/14483] More aggressive compare insn elimination X-Bugzilla-Reason: CC X-SW-Source: 2004-03/txt/msg01019.txt.bz2 List-Id: ------- Additional Comments From kazu at cs dot umass dot edu 2004-03-08 19:51 ------- I created a simple patch to *detect* where the proposed optimization would trigger. Testing with a recent version of GCC shows this optimization would occur 27 times on all C source files directly under gcc/. Of those, 25 of them have "cmp $1" followed by "testl". The rest have "cmp $32" followed by "cmp $31" used to determine LE (signed less than or equal to). (That is, we can omit "cmp $31" and use LT instead). The problem with extending cse_condition_code_reg() in cse.c is that we have to determine the result of "testl", (reg 17) dies at the conditional jump insn, but cse_condition_code_reg() is run before the flow analysis. So we don't have liveness information. If this is to be implemented, we may have to do this after the combine or something. Index: cse.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cse.c,v retrieving revision 1.229.2.31 diff -u -r1.229.2.31 cse.c --- cse.c 5 Mar 2004 23:48:13 -0000 1.229.2.31 +++ cse.c 8 Mar 2004 19:36:23 -0000 @@ -7711,6 +7711,30 @@ && (can_change_mode || comp_mode == mode)) found = true; } + else if (GET_CODE (cc_src) == COMPARE + && GET_CODE (SET_SRC (set)) == COMPARE + && rtx_equal_p (XEXP (cc_src, 0), + XEXP (SET_SRC (set), 0)) + && GET_CODE (XEXP (cc_src, 1)) == CONST_INT + && GET_CODE (XEXP (SET_SRC (set), 1)) == CONST_INT + && (INTVAL (XEXP (cc_src, 1)) + == INTVAL (XEXP (SET_SRC (set), 1)) + 1) + && GET_CODE (BB_END (e->dest)) == JUMP_INSN) + { + rtx old_set = single_set (BB_END (e->dest)); + + if (old_set + && SET_DEST (old_set) == pc_rtx + && GET_CODE (SET_SRC (old_set)) == IF_THEN_ELSE) + { + rtx old_if_then_else = SET_SRC (old_set); + if (GET_CODE (XEXP (old_if_then_else, 0)) == LE + || GET_CODE (XEXP (old_if_then_else, 0)) == LEU + || (GET_CODE (XEXP (old_if_then_else, 0)) == EQ + && XEXP (SET_SRC (set), 1) == const0_rtx)) + debug_rtx (insn); + } + } if (found) { -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14483