Commit a49a6a68 by John Wehle Committed by John Wehle

loop.c (canonicalize_condition): New function, broken out of get_condition.

	* loop.c (canonicalize_condition): New function,
	broken out of get_condition.
	(get_condition): Use it.
	* expr.h (canonicalize_condition): Prototype it.

	* tree.h (tree_int_cst_msb): Declare.
	* tree.c (tree_int_cst_msb): New function.

From-SVN: r32045
parent 930b1f40
Fri Feb 18 01:29:22 EST 2000 John Wehle (john@feith.com)
* loop.c (canonicalize_condition): New function,
broken out of get_condition.
(get_condition): Use it.
* expr.h (canonicalize_condition): Prototype it.
* tree.h (tree_int_cst_msb): Declare.
* tree.c (tree_int_cst_msb): New function.
2000-02-17 Mark Mitchell <mark@codesourcery.com> 2000-02-17 Mark Mitchell <mark@codesourcery.com>
* stmt.c (set_file_and_line_for_stmt): Don't crash if cfun->stmt * stmt.c (set_file_and_line_for_stmt): Don't crash if cfun->stmt
......
...@@ -888,7 +888,12 @@ extern rtx emit_store_flag_force PARAMS ((rtx, enum rtx_code, rtx, rtx, ...@@ -888,7 +888,12 @@ extern rtx emit_store_flag_force PARAMS ((rtx, enum rtx_code, rtx, rtx,
/* Functions from loop.c: */ /* Functions from loop.c: */
/* Given a JUMP_INSN, return a description of the test being made. */ /* Given an insn and condition, return a canonical description of
the test being made. */
extern rtx canonicalize_condition PARAMS ((rtx, rtx, int, rtx *));
/* Given a JUMP_INSN, return a canonical description of the test
being made. */
extern rtx get_condition PARAMS ((rtx, rtx *)); extern rtx get_condition PARAMS ((rtx, rtx *));
/* Generate a conditional trap instruction. */ /* Generate a conditional trap instruction. */
......
...@@ -8995,32 +8995,34 @@ update_reg_last_use (x, insn) ...@@ -8995,32 +8995,34 @@ update_reg_last_use (x, insn)
} }
} }
/* Given a jump insn JUMP, return the condition that will cause it to branch /* Given an insn INSN and condition COND, return the condition in a
to its JUMP_LABEL. If the condition cannot be understood, or is an canonical form to simplify testing by callers. Specifically:
inequality floating-point comparison which needs to be reversed, 0 will
be returned.
If EARLIEST is non-zero, it is a pointer to a place where the earliest
insn used in locating the condition was found. If a replacement test
of the condition is desired, it should be placed in front of that
insn and we will be sure that the inputs are still valid.
The condition will be returned in a canonical form to simplify testing by
callers. Specifically:
(1) The code will always be a comparison operation (EQ, NE, GT, etc.). (1) The code will always be a comparison operation (EQ, NE, GT, etc.).
(2) Both operands will be machine operands; (cc0) will have been replaced. (2) Both operands will be machine operands; (cc0) will have been replaced.
(3) If an operand is a constant, it will be the second operand. (3) If an operand is a constant, it will be the second operand.
(4) (LE x const) will be replaced with (LT x <const+1>) and similarly (4) (LE x const) will be replaced with (LT x <const+1>) and similarly
for GE, GEU, and LEU. */ for GE, GEU, and LEU.
If the condition cannot be understood, or is an inequality floating-point
comparison which needs to be reversed, 0 will be returned.
If REVERSE is non-zero, then reverse the condition prior to canonizing it.
If EARLIEST is non-zero, it is a pointer to a place where the earliest
insn used in locating the condition was found. If a replacement test
of the condition is desired, it should be placed in front of that
insn and we will be sure that the inputs are still valid. */
rtx rtx
get_condition (jump, earliest) canonicalize_condition (insn, cond, reverse, earliest)
rtx jump; rtx insn;
rtx cond;
int reverse;
rtx *earliest; rtx *earliest;
{ {
enum rtx_code code; enum rtx_code code;
rtx prev = jump; rtx prev = insn;
rtx set; rtx set;
rtx tem; rtx tem;
rtx op0, op1; rtx op0, op1;
...@@ -9028,24 +9030,19 @@ get_condition (jump, earliest) ...@@ -9028,24 +9030,19 @@ get_condition (jump, earliest)
int did_reverse_condition = 0; int did_reverse_condition = 0;
enum machine_mode mode; enum machine_mode mode;
/* If this is not a standard conditional jump, we can't parse it. */ code = GET_CODE (cond);
if (GET_CODE (jump) != JUMP_INSN mode = GET_MODE (cond);
|| ! condjump_p (jump) || simplejump_p (jump)) op0 = XEXP (cond, 0);
return 0; op1 = XEXP (cond, 1);
code = GET_CODE (XEXP (SET_SRC (PATTERN (jump)), 0)); if (reverse)
mode = GET_MODE (XEXP (SET_SRC (PATTERN (jump)), 0)); {
op0 = XEXP (XEXP (SET_SRC (PATTERN (jump)), 0), 0); code = reverse_condition (code);
op1 = XEXP (XEXP (SET_SRC (PATTERN (jump)), 0), 1); did_reverse_condition ^= 1;
}
if (earliest) if (earliest)
*earliest = jump; *earliest = insn;
/* If this branches to JUMP_LABEL when the condition is false, reverse
the condition. */
if (GET_CODE (XEXP (SET_SRC (PATTERN (jump)), 2)) == LABEL_REF
&& XEXP (XEXP (SET_SRC (PATTERN (jump)), 2), 0) == JUMP_LABEL (jump))
code = reverse_condition (code), did_reverse_condition ^= 1;
/* If we are comparing a register with zero, see if the register is set /* If we are comparing a register with zero, see if the register is set
in the previous insn to a COMPARE or a comparison operation. Perform in the previous insn to a COMPARE or a comparison operation. Perform
...@@ -9262,6 +9259,40 @@ get_condition (jump, earliest) ...@@ -9262,6 +9259,40 @@ get_condition (jump, earliest)
return gen_rtx_fmt_ee (code, VOIDmode, op0, op1); return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
} }
/* Given a jump insn JUMP, return the condition that will cause it to branch
to its JUMP_LABEL. If the condition cannot be understood, or is an
inequality floating-point comparison which needs to be reversed, 0 will
be returned.
If EARLIEST is non-zero, it is a pointer to a place where the earliest
insn used in locating the condition was found. If a replacement test
of the condition is desired, it should be placed in front of that
insn and we will be sure that the inputs are still valid. */
rtx
get_condition (jump, earliest)
rtx jump;
rtx *earliest;
{
rtx cond;
int reverse;
/* If this is not a standard conditional jump, we can't parse it. */
if (GET_CODE (jump) != JUMP_INSN
|| ! condjump_p (jump) || simplejump_p (jump))
return 0;
cond = XEXP (SET_SRC (PATTERN (jump)), 0);
/* If this branches to JUMP_LABEL when the condition is false, reverse
the condition. */
reverse
= GET_CODE (XEXP (SET_SRC (PATTERN (jump)), 2)) == LABEL_REF
&& XEXP (XEXP (SET_SRC (PATTERN (jump)), 2), 0) == JUMP_LABEL (jump);
return canonicalize_condition (jump, cond, reverse, earliest);
}
/* Similar to above routine, except that we also put an invariant last /* Similar to above routine, except that we also put an invariant last
unless both operands are invariants. */ unless both operands are invariants. */
......
...@@ -4062,6 +4062,24 @@ tree_int_cst_lt (t1, t2) ...@@ -4062,6 +4062,24 @@ tree_int_cst_lt (t1, t2)
return INT_CST_LT_UNSIGNED (t1, t2); return INT_CST_LT_UNSIGNED (t1, t2);
} }
/* Return the most significant bit of the integer constant T. */
int
tree_int_cst_msb (t)
tree t;
{
register int prec;
HOST_WIDE_INT h;
HOST_WIDE_INT l;
/* Note that using TYPE_PRECISION here is wrong. We care about the
actual bits, not the (arbitrary) range of the type. */
prec = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (t))) - 1;
rshift_double (TREE_INT_CST_LOW (t), TREE_INT_CST_HIGH (t), prec,
2 * HOST_BITS_PER_WIDE_INT, &l, &h, 0);
return (l & 1) == 1;
}
/* Return an indication of the sign of the integer constant T. /* Return an indication of the sign of the integer constant T.
The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0. The return value is -1 if T < 0, 0 if T == 0, and 1 if T > 0.
Note that -1 will never be returned it T's type is unsigned. */ Note that -1 will never be returned it T's type is unsigned. */
......
...@@ -1666,6 +1666,7 @@ extern int attribute_list_equal PARAMS ((tree, tree)); ...@@ -1666,6 +1666,7 @@ extern int attribute_list_equal PARAMS ((tree, tree));
extern int attribute_list_contained PARAMS ((tree, tree)); extern int attribute_list_contained PARAMS ((tree, tree));
extern int tree_int_cst_equal PARAMS ((tree, tree)); extern int tree_int_cst_equal PARAMS ((tree, tree));
extern int tree_int_cst_lt PARAMS ((tree, tree)); extern int tree_int_cst_lt PARAMS ((tree, tree));
extern int tree_int_cst_msb PARAMS ((tree));
extern int tree_int_cst_sgn PARAMS ((tree)); extern int tree_int_cst_sgn PARAMS ((tree));
extern int index_type_equal PARAMS ((tree, tree)); extern int index_type_equal PARAMS ((tree, tree));
extern tree get_inner_array_type PARAMS ((tree)); extern tree get_inner_array_type PARAMS ((tree));
......
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