From 90a747032a88e99270a882e1d33a87fd55ef8520 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Fri, 5 Jan 2001 16:34:39 +0100 Subject: [PATCH] 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 --- gcc/ChangeLog | 16 ++++++++++++++++ gcc/emit-rtl.c | 20 ++++++------------- gcc/jump.c | 5 ++--- gcc/predict.c | 10 +++++++++- gcc/reg-stack.c | 14 ++++++++++++-- gcc/rtl.h | 3 ++- gcc/simplify-rtx.c | 48 ++++++++++++++++++++++++++++++++++++++++++---- 7 files changed, 91 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d06ad0a1630..6a12ecae04c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +Fri Jan 5 16:29:49 MET 2001 Jan Hubicka + + * 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 * cpp.texi: Update for -MP. Clarify behaviour of -MT. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 9f2a4ae4595..0206bbdc008 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1,6 +1,6 @@ /* Emit RTL for the GNU C-Compiler expander. 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. @@ -2433,19 +2433,11 @@ try_split (pat, trial, last) && rtx_equal_p (PATTERN (XVECEXP (seq, 0, i)), pat)) return trial; - /* If we are splitting a JUMP_INSN, look for the JUMP_INSN in - SEQ and copy our JUMP_LABEL to it. If JUMP_LABEL is non-zero, - increment the usage count so we don't delete the label. */ - - if (GET_CODE (trial) == JUMP_INSN) - 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))++; - } + /* Mark labels. */ + for (i = XVECLEN (seq, 0) - 1; i >= 0; i--) + if (GET_CODE (XVECEXP (seq, 0, i)) == JUMP_INSN) + mark_jump_label (PATTERN (XVECEXP (seq, 0, i)), + XVECEXP (seq, 0, i), 0, 0); /* If we are splitting a CALL_INSN, look for the CALL_INSN in SEQ and copy our CALL_INSN_FUNCTION_USAGE to it. */ diff --git a/gcc/jump.c b/gcc/jump.c index f4845b8e484..1c6c3a633d6 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -1,6 +1,6 @@ /* Optimize jump instructions, for GNU compiler. 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. @@ -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 int jump_back_p PARAMS ((rtx, rtx)); 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 redirect_exp_1 PARAMS ((rtx *, rtx, rtx, rtx)); static int redirect_exp PARAMS ((rtx, rtx, rtx)); @@ -2377,7 +2376,7 @@ tension_vector_labels (x, idx) 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. */ -static void +void mark_jump_label (x, insn, cross_jump, in_mem) register rtx x; rtx insn; diff --git a/gcc/predict.c b/gcc/predict.c index 57595ed9488..d598ef92e6c 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -1,5 +1,5 @@ /* 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. @@ -183,11 +183,19 @@ estimate_probability (loops_info) goto emitnote; case EQ: + case UNEQ: prob = PROB_UNLIKELY; goto emitnote; case NE: + case LTGT: prob = PROB_LIKELY; goto emitnote; + case ORDERED: + prob = PROB_LIKELY; + goto emitnote; + case UNORDERED: + prob = PROB_UNLIKELY; + goto emitnote; case LE: case LT: if (XEXP (cond, 1) == const0_rtx) diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c index 0063cbdbdaa..48dd3bd6966 100644 --- a/gcc/reg-stack.c +++ b/gcc/reg-stack.c @@ -1,6 +1,6 @@ /* Register to Stack convert for GNU compiler. 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. @@ -1261,7 +1261,17 @@ swap_rtx_condition (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 diff --git a/gcc/rtl.h b/gcc/rtl.h index c3878774d2f..bb353be4dfb 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1,6 +1,6 @@ /* Register Transfer Language (RTL) definitions for GNU C-Compiler 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. @@ -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 unsigned_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 */ extern rtx find_equiv_reg PARAMS ((rtx, rtx, enum reg_class, int, short *, int, enum machine_mode)); diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 03a2b608026..13d693cbdfe 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1,6 +1,6 @@ /* RTL simplification functions for GNU compiler. 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. @@ -1676,6 +1676,7 @@ struct cfc_args { rtx op0, op1; /* Input */ int equal, op0lt, op1lt; /* Output */ + int unordered; }; static void @@ -1685,11 +1686,19 @@ check_fold_consts (data) struct cfc_args *args = (struct cfc_args *) data; 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 (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->op0lt = REAL_VALUES_LESS (d0, d1); args->op1lt = REAL_VALUES_LESS (d1, d0); + args->unordered = 0; } /* Like simplify_binary_operation except used for relational operators. @@ -1772,9 +1781,32 @@ simplify_relational_operation (code, mode, op0, op1) args.op0 = op0; args.op1 = op1; - if (do_float_handler(check_fold_consts, (PTR) &args) == 0) - /* We got an exception from check_fold_consts() */ - return 0; + + if (!do_float_handler(check_fold_consts, (PTR) &args)) + 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() */ equal = args.equal; @@ -1905,12 +1937,16 @@ simplify_relational_operation (code, mode, op0, op1) switch (code) { case EQ: + case UNEQ: return equal ? const_true_rtx : const0_rtx; case NE: + case LTGT: return ! equal ? const_true_rtx : const0_rtx; case LT: + case UNLT: return op0lt ? const_true_rtx : const0_rtx; case GT: + case UNGT: return op1lt ? const_true_rtx : const0_rtx; case LTU: return op0ltu ? const_true_rtx : const0_rtx; @@ -1924,6 +1960,10 @@ simplify_relational_operation (code, mode, op0, op1) return equal || op0ltu ? const_true_rtx : const0_rtx; case GEU: return equal || op1ltu ? const_true_rtx : const0_rtx; + case ORDERED: + return const_true_rtx; + case UNORDERED: + return const0_rtx; default: abort (); }