Commit 6db21c7f by Richard Henderson Committed by Richard Henderson

alpha.h (alpha_compare): New.

        * alpha.h (alpha_compare): New.
        (alpha_compare_op0, alpha_compare_op1, alpha_compare_fp_p): Remove.
        * alpha.c: Likewise for the definitions.
        (alpha_emit_conditional_branch): Update for alpha_compare.
        (alpha_emit_conditional_move): Likewise.
        * alpha.md (cmpdf, cmpdi): Likewise.
        (setcc patterns): Likewise.  Zero alpha_compare after use.
        (sne): Optimize (x != 0) into (0U < x).

From-SVN: r29183
parent 01439aee
Tue Sep 7 22:09:03 1999 Richard Henderson <rth@cygnus.com>
* alpha.h (alpha_compare): New.
(alpha_compare_op0, alpha_compare_op1, alpha_compare_fp_p): Remove.
* alpha.c: Likewise for the definitions.
(alpha_emit_conditional_branch): Update for alpha_compare.
(alpha_emit_conditional_move): Likewise.
* alpha.md (cmpdf, cmpdi): Likewise.
(setcc patterns): Likewise. Zero alpha_compare after use.
(sne): Optimize (x != 0) into (0U < x).
Tue Sep 7 21:55:02 1999 Richard Henderson <rth@cygnus.com> Tue Sep 7 21:55:02 1999 Richard Henderson <rth@cygnus.com>
* alpha.h (alpha_eh_epilogue_sp_ofs): Remove. * alpha.h (alpha_eh_epilogue_sp_ofs): Remove.
......
...@@ -77,8 +77,7 @@ const char *alpha_mlat_string; /* -mmemory-latency= */ ...@@ -77,8 +77,7 @@ const char *alpha_mlat_string; /* -mmemory-latency= */
/* Save information from a "cmpxx" operation until the branch or scc is /* Save information from a "cmpxx" operation until the branch or scc is
emitted. */ emitted. */
rtx alpha_compare_op0, alpha_compare_op1; struct alpha_compare alpha_compare;
int alpha_compare_fp_p;
/* Non-zero if inside of a function, because the Alpha asm can't /* Non-zero if inside of a function, because the Alpha asm can't
handle .files inside of functions. */ handle .files inside of functions. */
...@@ -1355,7 +1354,7 @@ alpha_emit_conditional_branch (code) ...@@ -1355,7 +1354,7 @@ alpha_emit_conditional_branch (code)
{ {
enum rtx_code cmp_code, branch_code; enum rtx_code cmp_code, branch_code;
enum machine_mode cmp_mode, branch_mode = VOIDmode; enum machine_mode cmp_mode, branch_mode = VOIDmode;
rtx op0 = alpha_compare_op0, op1 = alpha_compare_op1; rtx op0 = alpha_compare.op0, op1 = alpha_compare.op1;
rtx tem; rtx tem;
/* The general case: fold the comparison code to the types of compares /* The general case: fold the comparison code to the types of compares
...@@ -1374,7 +1373,7 @@ alpha_emit_conditional_branch (code) ...@@ -1374,7 +1373,7 @@ alpha_emit_conditional_branch (code)
case GE: case GT: case GEU: case GTU: case GE: case GT: case GEU: case GTU:
/* For FP, we swap them, for INT, we reverse them. */ /* For FP, we swap them, for INT, we reverse them. */
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
{ {
cmp_code = swap_condition (code); cmp_code = swap_condition (code);
branch_code = NE; branch_code = NE;
...@@ -1391,7 +1390,7 @@ alpha_emit_conditional_branch (code) ...@@ -1391,7 +1390,7 @@ alpha_emit_conditional_branch (code)
abort (); abort ();
} }
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
{ {
cmp_mode = DFmode; cmp_mode = DFmode;
if (flag_fast_math) if (flag_fast_math)
...@@ -1457,6 +1456,9 @@ alpha_emit_conditional_branch (code) ...@@ -1457,6 +1456,9 @@ alpha_emit_conditional_branch (code)
emit_move_insn (tem, gen_rtx_fmt_ee (cmp_code, cmp_mode, op0, op1)); emit_move_insn (tem, gen_rtx_fmt_ee (cmp_code, cmp_mode, op0, op1));
} }
/* Zero the operands. */
memset (&alpha_compare, 0, sizeof (alpha_compare));
/* Return the branch comparison. */ /* Return the branch comparison. */
return gen_rtx_fmt_ee (branch_code, branch_mode, tem, CONST0_RTX (cmp_mode)); return gen_rtx_fmt_ee (branch_code, branch_mode, tem, CONST0_RTX (cmp_mode));
} }
...@@ -1475,21 +1477,25 @@ alpha_emit_conditional_move (cmp, mode) ...@@ -1475,21 +1477,25 @@ alpha_emit_conditional_move (cmp, mode)
{ {
enum rtx_code code = GET_CODE (cmp); enum rtx_code code = GET_CODE (cmp);
enum rtx_code cmov_code = NE; enum rtx_code cmov_code = NE;
rtx op0 = alpha_compare_op0; rtx op0 = alpha_compare.op0;
rtx op1 = alpha_compare_op1; rtx op1 = alpha_compare.op1;
int fp_p = alpha_compare.fp_p;
enum machine_mode cmp_mode enum machine_mode cmp_mode
= (GET_MODE (op0) == VOIDmode ? DImode : GET_MODE (op0)); = (GET_MODE (op0) == VOIDmode ? DImode : GET_MODE (op0));
enum machine_mode cmp_op_mode = alpha_compare_fp_p ? DFmode : DImode; enum machine_mode cmp_op_mode = fp_p ? DFmode : DImode;
enum machine_mode cmov_mode = VOIDmode; enum machine_mode cmov_mode = VOIDmode;
rtx tem; rtx tem;
if (alpha_compare_fp_p != FLOAT_MODE_P (mode)) /* Zero the operands. */
memset (&alpha_compare, 0, sizeof (alpha_compare));
if (fp_p != FLOAT_MODE_P (mode))
return 0; return 0;
/* We may be able to use a conditional move directly. /* We may be able to use a conditional move directly.
This avoids emitting spurious compares. */ This avoids emitting spurious compares. */
if (signed_comparison_operator (cmp, cmp_op_mode) if (signed_comparison_operator (cmp, cmp_op_mode)
&& (!alpha_compare_fp_p || flag_fast_math) && (!fp_p || flag_fast_math)
&& (op0 == CONST0_RTX (cmp_mode) || op1 == CONST0_RTX (cmp_mode))) && (op0 == CONST0_RTX (cmp_mode) || op1 == CONST0_RTX (cmp_mode)))
return gen_rtx_fmt_ee (code, VOIDmode, op0, op1); return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
...@@ -1525,7 +1531,7 @@ alpha_emit_conditional_move (cmp, mode) ...@@ -1525,7 +1531,7 @@ alpha_emit_conditional_move (cmp, mode)
/* ??? We mark the branch mode to be CCmode to prevent the compare /* ??? We mark the branch mode to be CCmode to prevent the compare
and cmov from being combined, since the compare insn follows IEEE and cmov from being combined, since the compare insn follows IEEE
rules that the cmov does not. */ rules that the cmov does not. */
if (alpha_compare_fp_p && !flag_fast_math) if (fp_p && !flag_fast_math)
cmov_mode = CCmode; cmov_mode = CCmode;
tem = gen_reg_rtx (cmp_op_mode); tem = gen_reg_rtx (cmp_op_mode);
......
...@@ -1197,8 +1197,13 @@ extern struct rtx_def *alpha_emit_conditional_move (); ...@@ -1197,8 +1197,13 @@ extern struct rtx_def *alpha_emit_conditional_move ();
stored from the compare operation. Note that we can't use "rtx" here stored from the compare operation. Note that we can't use "rtx" here
since it hasn't been defined! */ since it hasn't been defined! */
extern struct rtx_def *alpha_compare_op0, *alpha_compare_op1; struct alpha_compare
extern int alpha_compare_fp_p; {
struct rtx_def *op0, *op1;
int fp_p;
};
extern struct alpha_compare alpha_compare;
/* Machine specific function data. */ /* Machine specific function data. */
......
...@@ -2916,9 +2916,9 @@ ...@@ -2916,9 +2916,9 @@
"TARGET_FP" "TARGET_FP"
" "
{ {
alpha_compare_op0 = operands[0]; alpha_compare.op0 = operands[0];
alpha_compare_op1 = operands[1]; alpha_compare.op1 = operands[1];
alpha_compare_fp_p = 1; alpha_compare.fp_p = 1;
DONE; DONE;
}") }")
...@@ -2928,9 +2928,9 @@ ...@@ -2928,9 +2928,9 @@
"" ""
" "
{ {
alpha_compare_op0 = operands[0]; alpha_compare.op0 = operands[0];
alpha_compare_op1 = operands[1]; alpha_compare.op1 = operands[1];
alpha_compare_fp_p = 0; alpha_compare.fp_p = 0;
DONE; DONE;
}") }")
...@@ -3020,10 +3020,11 @@ ...@@ -3020,10 +3020,11 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_EQ (DImode, alpha_compare_op0, alpha_compare_op1); operands[1] = gen_rtx_EQ (DImode, alpha_compare.op0, alpha_compare.op1);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sne" (define_expand "sne"
...@@ -3033,10 +3034,17 @@ ...@@ -3033,10 +3034,17 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_EQ (DImode, alpha_compare_op0, alpha_compare_op1); if (alpha_compare.op1 == const0_rtx)
{
emit_insn (gen_sgtu (operands[0]));
DONE;
}
operands[1] = gen_rtx_EQ (DImode, alpha_compare.op0, alpha_compare.op1);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "slt" (define_expand "slt"
...@@ -3045,10 +3053,11 @@ ...@@ -3045,10 +3053,11 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LT (DImode, alpha_compare_op0, alpha_compare_op1); operands[1] = gen_rtx_LT (DImode, alpha_compare.op0, alpha_compare.op1);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sle" (define_expand "sle"
...@@ -3057,10 +3066,11 @@ ...@@ -3057,10 +3066,11 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LE (DImode, alpha_compare_op0, alpha_compare_op1); operands[1] = gen_rtx_LE (DImode, alpha_compare.op0, alpha_compare.op1);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sgt" (define_expand "sgt"
...@@ -3069,11 +3079,12 @@ ...@@ -3069,11 +3079,12 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LT (DImode, force_reg (DImode, alpha_compare_op1), operands[1] = gen_rtx_LT (DImode, force_reg (DImode, alpha_compare.op1),
alpha_compare_op0); alpha_compare.op0);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sge" (define_expand "sge"
...@@ -3082,11 +3093,12 @@ ...@@ -3082,11 +3093,12 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LE (DImode, force_reg (DImode, alpha_compare_op1), operands[1] = gen_rtx_LE (DImode, force_reg (DImode, alpha_compare.op1),
alpha_compare_op0); alpha_compare.op0);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sltu" (define_expand "sltu"
...@@ -3095,10 +3107,11 @@ ...@@ -3095,10 +3107,11 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LTU (DImode, alpha_compare_op0, alpha_compare_op1); operands[1] = gen_rtx_LTU (DImode, alpha_compare.op0, alpha_compare.op1);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sleu" (define_expand "sleu"
...@@ -3107,10 +3120,11 @@ ...@@ -3107,10 +3120,11 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LEU (DImode, alpha_compare_op0, alpha_compare_op1); operands[1] = gen_rtx_LEU (DImode, alpha_compare.op0, alpha_compare.op1);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sgtu" (define_expand "sgtu"
...@@ -3119,11 +3133,12 @@ ...@@ -3119,11 +3133,12 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LTU (DImode, force_reg (DImode, alpha_compare_op1), operands[1] = gen_rtx_LTU (DImode, force_reg (DImode, alpha_compare.op1),
alpha_compare_op0); alpha_compare.op0);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
(define_expand "sgeu" (define_expand "sgeu"
...@@ -3132,11 +3147,12 @@ ...@@ -3132,11 +3147,12 @@
"" ""
" "
{ {
if (alpha_compare_fp_p) if (alpha_compare.fp_p)
FAIL; FAIL;
operands[1] = gen_rtx_LEU (DImode, force_reg (DImode, alpha_compare_op1), operands[1] = gen_rtx_LEU (DImode, force_reg (DImode, alpha_compare.op1),
alpha_compare_op0); alpha_compare.op0);
alpha_compare.op0 = alpha_compare.op1 = NULL_RTX;
}") }")
;; These are the main define_expand's used to make conditional moves. ;; These are the main define_expand's used to make conditional moves.
......
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