This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.4-BIB] Fix infinite recursion during ADA bootstrap on i486
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, aj at suse dot de
- Date: Sat, 30 Nov 2002 17:13:25 +0100
- Subject: [3.4-BIB] Fix infinite recursion during ADA bootstrap on i486
Hi,
ADA bootstrap on i486/BIB branch locks because of infinite recursion in
ix86_expand_int_movcc. THis happends only for HImode operands (we wasn't
converting previously) and due to fact that I disabled the constants handling.
Function recurses later assuming that it will pass in next iteration but it doesn't.
I've reviewed the code, made it working well for HImodes on !PARTIAL_REG_STALLS machines,
added explicit checks to kill recursion and spot other tiny bug in BRANCH_COST handling.
I've regtested and bootstrapped the patch on i386.
OK for BIB branch?
Honza
Sat Nov 30 17:09:33 CET 2002 Jan Hubicka <jh@suse.cz>
* i386.c (ix86_expand_int_movcc): Always optimize constants;
promote HImode to SImode early; fix reversed BRANCH_COST test;
be curefull about infinite recursion.
Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.490.2.5
diff -c -3 -p -r1.490.2.5 i386.c
*** i386.c 28 Nov 2002 23:19:47 -0000 1.490.2.5
--- i386.c 30 Nov 2002 16:09:26 -0000
*************** ix86_expand_int_movcc (operands)
*** 9173,9180 ****
/* Don't attempt mode expansion here -- if we had to expand 5 or 6
HImode insns, we'd be swallowed in word prefix ops. */
! if ((mode != HImode || TARGET_FAST_PREFIX)
! && (mode != DImode || TARGET_64BIT)
&& GET_CODE (operands[2]) == CONST_INT
&& GET_CODE (operands[3]) == CONST_INT)
{
--- 9173,9179 ----
/* Don't attempt mode expansion here -- if we had to expand 5 or 6
HImode insns, we'd be swallowed in word prefix ops. */
! if ((mode != DImode || TARGET_64BIT)
&& GET_CODE (operands[2]) == CONST_INT
&& GET_CODE (operands[3]) == CONST_INT)
{
*************** ix86_expand_int_movcc (operands)
*** 9183,9188 ****
--- 9182,9195 ----
HOST_WIDE_INT cf = INTVAL (operands[3]);
HOST_WIDE_INT diff;
+ /* Promote OUT into SImode to avoid extra prefix operations.
+ Since we can generate minus and neg, we can't rely on insn splitting
+ to do the job. */
+ if (GET_MODE (out) == HImode
+ && !TARGET_PARTIAL_REG_STALL
+ && (REG_P (out) || GET_CODE (out) == SUBREG))
+ out = gen_lowpart (SImode, out);
+
diff = ct - cf;
/* Sign bit compares are better done using shifts than we do by using
sbb. */
*************** ix86_expand_int_movcc (operands)
*** 9546,9552 ****
optab op;
rtx var, orig_out, out, tmp;
! if (BRANCH_COST >= 2)
return 0; /* FAIL */
/* If one of the two operands is an interesting constant, load a
--- 9553,9559 ----
optab op;
rtx var, orig_out, out, tmp;
! if (BRANCH_COST <= 2)
return 0; /* FAIL */
/* If one of the two operands is an interesting constant, load a
*************** ix86_expand_int_movcc (operands)
*** 9555,9563 ****
if (GET_CODE (operands[2]) == CONST_INT)
{
var = operands[3];
! if (INTVAL (operands[2]) == 0)
operands[3] = constm1_rtx, op = and_optab;
! else if (INTVAL (operands[2]) == -1)
operands[3] = const0_rtx, op = ior_optab;
else
return 0; /* FAIL */
--- 9562,9570 ----
if (GET_CODE (operands[2]) == CONST_INT)
{
var = operands[3];
! if (INTVAL (operands[2]) == 0 && operands[3] != constm1_rtx)
operands[3] = constm1_rtx, op = and_optab;
! else if (INTVAL (operands[2]) == -1 && operands[3] != const0_rtx)
operands[3] = const0_rtx, op = ior_optab;
else
return 0; /* FAIL */
*************** ix86_expand_int_movcc (operands)
*** 9565,9573 ****
else if (GET_CODE (operands[3]) == CONST_INT)
{
var = operands[2];
! if (INTVAL (operands[3]) == 0)
operands[2] = constm1_rtx, op = and_optab;
! else if (INTVAL (operands[3]) == -1)
operands[2] = const0_rtx, op = ior_optab;
else
return 0; /* FAIL */
--- 9572,9580 ----
else if (GET_CODE (operands[3]) == CONST_INT)
{
var = operands[2];
! if (INTVAL (operands[3]) == 0 && operands[2] != constm1_rtx)
operands[2] = constm1_rtx, op = and_optab;
! else if (INTVAL (operands[3]) == -1 && operands[3] != const0_rtx)
operands[2] = const0_rtx, op = ior_optab;
else
return 0; /* FAIL */