Commit cab6e771 by Steven Bosscher

ifcvt.c (struct noce_if_info): Add then_else_reversed field.

	* ifcvt.c (struct noce_if_info): Add then_else_reversed field.
	(noce_get_alt_condition): Look at it to determine whether to
	reverse the condition or not.
	(noce_get_condition): Substitute the truth for lies.
	(noce_find_if_block): Set the then_else_reversed field.

From-SVN: r123327
parent ed31d14c
2007-03-29 Steven Bosscher <steven@gcc.gnu.org>
* ifcvt.c (struct noce_if_info): Add then_else_reversed field.
(noce_get_alt_condition): Look at it to determine whether to
reverse the condition or not.
(noce_get_condition): Substitute the truth for lies.
(noce_find_if_block): Set the then_else_reversed field.
2007-03-29 Lars Poeschel <larsi@wh2.tu-dresden.de> 2007-03-29 Lars Poeschel <larsi@wh2.tu-dresden.de>
* config/fr30/fr30.md (movdi): Do not accept immediates as the * config/fr30/fr30.md (movdi): Do not accept immediates as the
......
...@@ -621,6 +621,12 @@ struct noce_if_info ...@@ -621,6 +621,12 @@ struct noce_if_info
/* The SET_DEST of INSN_A. */ /* The SET_DEST of INSN_A. */
rtx x; rtx x;
/* True if this if block is not canonical. In the canonical form of
if blocks, the THEN_BB is the block reached via the fallthru edge
from TEST_BB. For the noce transformations, we allow the symmetric
form as well. */
bool then_else_reversed;
}; };
static rtx noce_emit_store_flag (struct noce_if_info *, rtx, int, int); static rtx noce_emit_store_flag (struct noce_if_info *, rtx, int, int);
...@@ -1503,6 +1509,8 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target, ...@@ -1503,6 +1509,8 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
reverse reverse
= GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF = GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
&& XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (if_info->jump); && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (if_info->jump);
if (if_info->then_else_reversed)
reverse = !reverse;
/* If we're looking for a constant, try to make the conditional /* If we're looking for a constant, try to make the conditional
have that constant in it. There are two reasons why it may have that constant in it. There are two reasons why it may
...@@ -2017,8 +2025,8 @@ noce_try_bitop (struct noce_if_info *if_info) ...@@ -2017,8 +2025,8 @@ noce_try_bitop (struct noce_if_info *if_info)
/* Similar to get_condition, only the resulting condition must be /* Similar to get_condition, only the resulting condition must be
valid at JUMP, instead of at EARLIEST. valid at JUMP, instead of at EARLIEST.
If THEN_ELSE_REVERSED is true, the fallthrough goes to the THEN If THEN_ELSE_REVERSED is true, the fallthrough does not go to the
block of the caller, and we have to reverse the condition. */ THEN block of the caller, and we have to reverse the condition. */
static rtx static rtx
noce_get_condition (rtx jump, rtx *earliest, bool then_else_reversed) noce_get_condition (rtx jump, rtx *earliest, bool then_else_reversed)
...@@ -2036,8 +2044,9 @@ noce_get_condition (rtx jump, rtx *earliest, bool then_else_reversed) ...@@ -2036,8 +2044,9 @@ noce_get_condition (rtx jump, rtx *earliest, bool then_else_reversed)
reverse = (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF reverse = (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF
&& XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump)); && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump));
/* We may have to reverse because the caller's if block is not canonical /* We may have to reverse because the caller's if block is not canonical,
(i.e. the ELSE block isn't the fallthrough block for the TEST block). */ i.e. the THEN block isn't the fallthrough block for the TEST block
(see find_if_header). */
if (then_else_reversed) if (then_else_reversed)
reverse = !reverse; reverse = !reverse;
...@@ -2735,6 +2744,7 @@ noce_find_if_block (basic_block test_bb, ...@@ -2735,6 +2744,7 @@ noce_find_if_block (basic_block test_bb,
if_info.join_bb = join_bb; if_info.join_bb = join_bb;
if_info.cond = cond; if_info.cond = cond;
if_info.jump = jump; if_info.jump = jump;
if_info.then_else_reversed = then_else_reversed;
/* Do the real work. */ /* Do the real work. */
......
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