Commit 90a74703 by Jan Hubicka Committed by Jan Hubicka

simplify-rtx.c (cfc_args): add "unordered" field.

	* simplify-rtx.c (cfc_args): add "unordered" field.
	(check_fold_consts): Set unordered field.
	(simplify_relational_operation): Simplify the unordered
	comparisons.

	* reg-stack.c (swap_rtx_condition): Ensure that the transformation
	is valid.

	* emit-rtl.c (try_split): Fix code to mark labels.
	* jump.c (mark_jump_label): Make global.
	* rtl.h (mark_jump_label): Declare.

	* predict.c (estimate_probability): Handle unordred comparisons.

From-SVN: r38711
parent bfa2cb33
Fri Jan 5 16:29:49 MET 2001 Jan Hubicka <jh@suse.cz>
* simplify-rtx.c (cfc_args): add "unordered" field.
(check_fold_consts): Set unordered field.
(simplify_relational_operation): Simplify the unordered
comparisons.
* reg-stack.c (swap_rtx_condition): Ensure that the transformation
is valid.
* emit-rtl.c (try_split): Fix code to mark labels.
* jump.c (mark_jump_label): Make global.
* rtl.h (mark_jump_label): Declare.
* predict.c (estimate_probability): Handle unordred comparisons.
2001-01-05 Neil Booth <neil@daikokuya.demon.co.uk> 2001-01-05 Neil Booth <neil@daikokuya.demon.co.uk>
* cpp.texi: Update for -MP. Clarify behaviour of -MT. * cpp.texi: Update for -MP. Clarify behaviour of -MT.
......
/* Emit RTL for the GNU C-Compiler expander. /* Emit RTL for the GNU C-Compiler expander.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -2433,19 +2433,11 @@ try_split (pat, trial, last) ...@@ -2433,19 +2433,11 @@ try_split (pat, trial, last)
&& rtx_equal_p (PATTERN (XVECEXP (seq, 0, i)), pat)) && rtx_equal_p (PATTERN (XVECEXP (seq, 0, i)), pat))
return trial; return trial;
/* If we are splitting a JUMP_INSN, look for the JUMP_INSN in /* Mark labels. */
SEQ and copy our JUMP_LABEL to it. If JUMP_LABEL is non-zero, for (i = XVECLEN (seq, 0) - 1; i >= 0; i--)
increment the usage count so we don't delete the label. */ if (GET_CODE (XVECEXP (seq, 0, i)) == JUMP_INSN)
mark_jump_label (PATTERN (XVECEXP (seq, 0, i)),
if (GET_CODE (trial) == JUMP_INSN) XVECEXP (seq, 0, i), 0, 0);
for (i = XVECLEN (seq, 0) - 1; i >= 0; i--)
if (GET_CODE (XVECEXP (seq, 0, i)) == JUMP_INSN)
{
JUMP_LABEL (XVECEXP (seq, 0, i)) = JUMP_LABEL (trial);
if (JUMP_LABEL (trial))
LABEL_NUSES (JUMP_LABEL (trial))++;
}
/* If we are splitting a CALL_INSN, look for the CALL_INSN /* If we are splitting a CALL_INSN, look for the CALL_INSN
in SEQ and copy our CALL_INSN_FUNCTION_USAGE to it. */ in SEQ and copy our CALL_INSN_FUNCTION_USAGE to it. */
......
/* Optimize jump instructions, for GNU compiler. /* Optimize jump instructions, for GNU compiler.
Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997 Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997
1998, 1999, 2000 Free Software Foundation, Inc. 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -113,7 +113,6 @@ static void find_cross_jump PARAMS ((rtx, rtx, int, rtx *, rtx *)); ...@@ -113,7 +113,6 @@ static void find_cross_jump PARAMS ((rtx, rtx, int, rtx *, rtx *));
static void do_cross_jump PARAMS ((rtx, rtx, rtx)); static void do_cross_jump PARAMS ((rtx, rtx, rtx));
static int jump_back_p PARAMS ((rtx, rtx)); static int jump_back_p PARAMS ((rtx, rtx));
static int tension_vector_labels PARAMS ((rtx, int)); static int tension_vector_labels PARAMS ((rtx, int));
static void mark_jump_label PARAMS ((rtx, rtx, int, int));
static void delete_computation PARAMS ((rtx)); static void delete_computation PARAMS ((rtx));
static void redirect_exp_1 PARAMS ((rtx *, rtx, rtx, rtx)); static void redirect_exp_1 PARAMS ((rtx *, rtx, rtx, rtx));
static int redirect_exp PARAMS ((rtx, rtx, rtx)); static int redirect_exp PARAMS ((rtx, rtx, rtx));
...@@ -2377,7 +2376,7 @@ tension_vector_labels (x, idx) ...@@ -2377,7 +2376,7 @@ tension_vector_labels (x, idx)
Once reload has completed (CROSS_JUMP non-zero), we need not consider Once reload has completed (CROSS_JUMP non-zero), we need not consider
two labels distinct if they are separated by only USE or CLOBBER insns. */ two labels distinct if they are separated by only USE or CLOBBER insns. */
static void void
mark_jump_label (x, insn, cross_jump, in_mem) mark_jump_label (x, insn, cross_jump, in_mem)
register rtx x; register rtx x;
rtx insn; rtx insn;
......
/* Branch prediction routines for the GNU compiler. /* Branch prediction routines for the GNU compiler.
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -183,11 +183,19 @@ estimate_probability (loops_info) ...@@ -183,11 +183,19 @@ estimate_probability (loops_info)
goto emitnote; goto emitnote;
case EQ: case EQ:
case UNEQ:
prob = PROB_UNLIKELY; prob = PROB_UNLIKELY;
goto emitnote; goto emitnote;
case NE: case NE:
case LTGT:
prob = PROB_LIKELY; prob = PROB_LIKELY;
goto emitnote; goto emitnote;
case ORDERED:
prob = PROB_LIKELY;
goto emitnote;
case UNORDERED:
prob = PROB_UNLIKELY;
goto emitnote;
case LE: case LE:
case LT: case LT:
if (XEXP (cond, 1) == const0_rtx) if (XEXP (cond, 1) == const0_rtx)
......
/* Register to Stack convert for GNU compiler. /* Register to Stack convert for GNU compiler.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -1261,7 +1261,17 @@ swap_rtx_condition (insn) ...@@ -1261,7 +1261,17 @@ swap_rtx_condition (insn)
pat = PATTERN (insn); pat = PATTERN (insn);
} }
return swap_rtx_condition_1 (pat); if (swap_rtx_condition_1 (pat))
{
INSN_CODE (insn) = -1;
if (recog_memoized (insn) == -1)
{
swap_rtx_condition_1 (pat);
return 0;
}
return 1;
}
return 0;
} }
/* Handle a comparison. Special care needs to be taken to avoid /* Handle a comparison. Special care needs to be taken to avoid
......
/* Register Transfer Language (RTL) definitions for GNU C-Compiler /* Register Transfer Language (RTL) definitions for GNU C-Compiler
Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -1287,6 +1287,7 @@ extern enum rtx_code reverse_condition_maybe_unordered PARAMS ((enum rtx_code)); ...@@ -1287,6 +1287,7 @@ extern enum rtx_code reverse_condition_maybe_unordered PARAMS ((enum rtx_code));
extern enum rtx_code swap_condition PARAMS ((enum rtx_code)); extern enum rtx_code swap_condition PARAMS ((enum rtx_code));
extern enum rtx_code unsigned_condition PARAMS ((enum rtx_code)); extern enum rtx_code unsigned_condition PARAMS ((enum rtx_code));
extern enum rtx_code signed_condition PARAMS ((enum rtx_code)); extern enum rtx_code signed_condition PARAMS ((enum rtx_code));
extern void mark_jump_label PARAMS ((rtx, rtx, int, int));
/* In reload.c */ /* In reload.c */
extern rtx find_equiv_reg PARAMS ((rtx, rtx, enum reg_class, int, short *, int, enum machine_mode)); extern rtx find_equiv_reg PARAMS ((rtx, rtx, enum reg_class, int, short *, int, enum machine_mode));
......
/* RTL simplification functions for GNU compiler. /* RTL simplification functions for GNU compiler.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -1676,6 +1676,7 @@ struct cfc_args ...@@ -1676,6 +1676,7 @@ struct cfc_args
{ {
rtx op0, op1; /* Input */ rtx op0, op1; /* Input */
int equal, op0lt, op1lt; /* Output */ int equal, op0lt, op1lt; /* Output */
int unordered;
}; };
static void static void
...@@ -1685,11 +1686,19 @@ check_fold_consts (data) ...@@ -1685,11 +1686,19 @@ check_fold_consts (data)
struct cfc_args *args = (struct cfc_args *) data; struct cfc_args *args = (struct cfc_args *) data;
REAL_VALUE_TYPE d0, d1; REAL_VALUE_TYPE d0, d1;
/* We may possibly raise an exception while reading the value. */
args->unordered = 1;
REAL_VALUE_FROM_CONST_DOUBLE (d0, args->op0); REAL_VALUE_FROM_CONST_DOUBLE (d0, args->op0);
REAL_VALUE_FROM_CONST_DOUBLE (d1, args->op1); REAL_VALUE_FROM_CONST_DOUBLE (d1, args->op1);
/* Comparisons of Inf versus Inf are ordered. */
if (REAL_VALUE_ISNAN (d0)
|| REAL_VALUE_ISNAN (d1))
return;
args->equal = REAL_VALUES_EQUAL (d0, d1); args->equal = REAL_VALUES_EQUAL (d0, d1);
args->op0lt = REAL_VALUES_LESS (d0, d1); args->op0lt = REAL_VALUES_LESS (d0, d1);
args->op1lt = REAL_VALUES_LESS (d1, d0); args->op1lt = REAL_VALUES_LESS (d1, d0);
args->unordered = 0;
} }
/* Like simplify_binary_operation except used for relational operators. /* Like simplify_binary_operation except used for relational operators.
...@@ -1772,9 +1781,32 @@ simplify_relational_operation (code, mode, op0, op1) ...@@ -1772,9 +1781,32 @@ simplify_relational_operation (code, mode, op0, op1)
args.op0 = op0; args.op0 = op0;
args.op1 = op1; args.op1 = op1;
if (do_float_handler(check_fold_consts, (PTR) &args) == 0)
/* We got an exception from check_fold_consts() */ if (!do_float_handler(check_fold_consts, (PTR) &args))
return 0; args.unordered = 1;
if (args.unordered)
switch (code)
{
case UNEQ:
case UNLT:
case UNGT:
case UNLE:
case UNGE:
case NE:
case UNORDERED:
return const_true_rtx;
case EQ:
case LT:
case GT:
case LE:
case GE:
case LTGT:
case ORDERED:
return const0_rtx;
default:
return 0;
}
/* Receive output from check_fold_consts() */ /* Receive output from check_fold_consts() */
equal = args.equal; equal = args.equal;
...@@ -1905,12 +1937,16 @@ simplify_relational_operation (code, mode, op0, op1) ...@@ -1905,12 +1937,16 @@ simplify_relational_operation (code, mode, op0, op1)
switch (code) switch (code)
{ {
case EQ: case EQ:
case UNEQ:
return equal ? const_true_rtx : const0_rtx; return equal ? const_true_rtx : const0_rtx;
case NE: case NE:
case LTGT:
return ! equal ? const_true_rtx : const0_rtx; return ! equal ? const_true_rtx : const0_rtx;
case LT: case LT:
case UNLT:
return op0lt ? const_true_rtx : const0_rtx; return op0lt ? const_true_rtx : const0_rtx;
case GT: case GT:
case UNGT:
return op1lt ? const_true_rtx : const0_rtx; return op1lt ? const_true_rtx : const0_rtx;
case LTU: case LTU:
return op0ltu ? const_true_rtx : const0_rtx; return op0ltu ? const_true_rtx : const0_rtx;
...@@ -1924,6 +1960,10 @@ simplify_relational_operation (code, mode, op0, op1) ...@@ -1924,6 +1960,10 @@ simplify_relational_operation (code, mode, op0, op1)
return equal || op0ltu ? const_true_rtx : const0_rtx; return equal || op0ltu ? const_true_rtx : const0_rtx;
case GEU: case GEU:
return equal || op1ltu ? const_true_rtx : const0_rtx; return equal || op1ltu ? const_true_rtx : const0_rtx;
case ORDERED:
return const_true_rtx;
case UNORDERED:
return const0_rtx;
default: default:
abort (); abort ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment