From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10487 invoked by alias); 28 May 2002 14:56:10 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10443 invoked by uid 71); 28 May 2002 14:56:05 -0000 Date: Tue, 28 May 2002 08:16:00 -0000 Message-ID: <20020528145605.10437.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Glen Nakamura Subject: Re: optimization/6822: GCC 3.1.1 - Internal compiler error in extract_insn, at recog.c:2132 Reply-To: Glen Nakamura X-SW-Source: 2002-05/txt/msg00910.txt.bz2 List-Id: The following reply was made to PR optimization/6822; it has been noted by GNATS. From: Glen Nakamura To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: optimization/6822: GCC 3.1.1 - Internal compiler error in extract_insn, at recog.c:2132 Date: Tue, 28 May 2002 04:49:41 -1000 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6822 2002-05-28 Glen Nakamura * fold-const.c (fold): Modify the transformation of a comparison against the highest or lowest integer value to adjust for the previous transformation which converts 'X >= CST to X > (CST - 1)' and 'X < CST to X <= (CST - 1)'. The patch allows the compiler to reduce unsigned X < ~0 to X != ~0. It also reduces unsigned X <= (~0 - 1) to X != ~0 which the original patch missed... e.g. gcc.c-torture/execute/loop-2c.c execution, -Os would fail again on i586-pc-linux-gnu if we changed: for (p = &a[b], i = b; --i < ~0; ) *--p = i * 3 + o; to: for (p = &a[b], i = b; --i <= (~0 - 1); ) *--p = i * 3 + o; With this patch, both cases should work... - Glen Nakamura --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fold.diff" Index: fold-const.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/fold-const.c,v retrieving revision 1.185.2.2 diff -c -3 -p -r1.185.2.2 fold-const.c *** fold-const.c 23 Apr 2002 23:20:00 -0000 1.185.2.2 --- fold-const.c 27 May 2002 21:11:18 -0000 *************** fold (expr) *** 6490,6496 **** } } ! /* Change X >= CST to X > (CST - 1) if CST is positive. */ if (TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (arg0) != INTEGER_CST && tree_int_cst_sgn (arg1) > 0) --- 6490,6497 ---- } } ! /* Change X >= CST to X > (CST - 1) and X < CST to X <= (CST - 1) ! if CST is positive. */ if (TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (arg0) != INTEGER_CST && tree_int_cst_sgn (arg1) > 0) *************** fold (expr) *** 6753,6777 **** return omit_one_operand (type, convert (type, integer_zero_node), arg0); - case GE_EXPR: - TREE_SET_CODE (t, EQ_EXPR); - break; - case LE_EXPR: return omit_one_operand (type, convert (type, integer_one_node), arg0); ! case LT_EXPR: ! TREE_SET_CODE (t, NE_EXPR); break; default: break; } else if (TREE_INT_CST_HIGH (arg1) == -1 && (TREE_INT_CST_LOW (arg1) ! == ((unsigned HOST_WIDE_INT) 1 << (width - 1))) && ! TREE_UNSIGNED (TREE_TYPE (arg1))) switch (TREE_CODE (t)) { --- 6754,6796 ---- return omit_one_operand (type, convert (type, integer_zero_node), arg0); case LE_EXPR: return omit_one_operand (type, convert (type, integer_one_node), arg0); ! ! /* The GE_EXPR and LT_EXPR cases are unnecessary because a ! previous optimization converted X >= CST to X > (CST - 1) ! and X < CST to X <= (CST - 1). These two cases are handled ! in the next switch statement. */ ! ! default: break; + } + else if (TREE_INT_CST_HIGH (arg1) == 0 + && (TREE_INT_CST_LOW (arg1) + == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 2) + && ! TREE_UNSIGNED (TREE_TYPE (arg1))) + switch (TREE_CODE (t)) + { + case GT_EXPR: + code = EQ_EXPR; + arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0); + t = build (code, type, TREE_OPERAND (t, 0), arg1); + break; + case LE_EXPR: + code = NE_EXPR; + arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0); + t = build (code, type, TREE_OPERAND (t, 0), arg1); + break; default: break; } else if (TREE_INT_CST_HIGH (arg1) == -1 && (TREE_INT_CST_LOW (arg1) ! == ((unsigned HOST_WIDE_INT) -1 << (width - 1))) && ! TREE_UNSIGNED (TREE_TYPE (arg1))) switch (TREE_CODE (t)) { *************** fold (expr) *** 6780,6785 **** --- 6799,6805 ---- convert (type, integer_zero_node), arg0); case LE_EXPR: + code = EQ_EXPR; TREE_SET_CODE (t, EQ_EXPR); break; *************** fold (expr) *** 6788,6793 **** --- 6808,6814 ---- convert (type, integer_one_node), arg0); case GT_EXPR: + code = NE_EXPR; TREE_SET_CODE (t, NE_EXPR); break; *************** fold (expr) *** 6830,6847 **** return omit_one_operand (type, convert (type, integer_zero_node), arg0); - case GE_EXPR: - TREE_SET_CODE (t, EQ_EXPR); - break; - case LE_EXPR: return omit_one_operand (type, convert (type, integer_one_node), arg0); ! case LT_EXPR: ! TREE_SET_CODE (t, NE_EXPR); break; default: break; } --- 6851,6886 ---- return omit_one_operand (type, convert (type, integer_zero_node), arg0); case LE_EXPR: return omit_one_operand (type, convert (type, integer_one_node), arg0); ! ! /* The GE_EXPR and LT_EXPR cases are unnecessary because a ! previous optimization converted X >= CST to X > (CST - 1) ! and X < CST to X <= (CST - 1). These two cases are handled ! in the next switch statement. */ ! ! default: break; + } + else if (TREE_INT_CST_HIGH (arg1) == 0 + && (TREE_INT_CST_LOW (arg1) + == ((unsigned HOST_WIDE_INT) 2 << (width - 1)) - 2) + && TREE_UNSIGNED (TREE_TYPE (arg1))) + switch (TREE_CODE (t)) + { + case GT_EXPR: + code = EQ_EXPR; + arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0); + t = build (code, type, TREE_OPERAND (t, 0), arg1); + break; + case LE_EXPR: + code = NE_EXPR; + arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0); + t = build (code, type, TREE_OPERAND (t, 0), arg1); + break; default: break; } --FL5UXtIhxfXey3p5--