Commit 0fe0c614 by Roger Sayle Committed by Roger Sayle

re PR middle-end/15825 (if-cvt optimisation patch noce_try_sign_mask breaks apple-ppc-darwin port)


	PR middle-end/15825
	* ifcvt.c (unshare_ifcvt_sequence): Rename to end_ifcvt_sequence.
	Use get_isns and end_sequence instead of accepting a seq argument.
	Scan the instruction sequence for unrecognizable or jump insns.
	(noce_try_move, noce_try_store_flag, noce_try_store_flag_constants,
	noce_try_addcc, noce_try_store_flag_mask, noce_try_cmove,
	noce_try_cmove_arith, noce_try_minmax, noce_try_abs,
	noce_try_sign_mask): Use end_ifcvt_sequence to factor common code.

	* gcc.dg/pr15825-1.c: New test case.

From-SVN: r83671
parent 71f85957
2004-06-25 Roger Sayle <roger@eyesopen.com>
PR middle-end/15825
* ifcvt.c (unshare_ifcvt_sequence): Rename to end_ifcvt_sequence.
Use get_isns and end_sequence instead of accepting a seq argument.
Scan the instruction sequence for unrecognizable or jump insns.
(noce_try_move, noce_try_store_flag, noce_try_store_flag_constants,
noce_try_addcc, noce_try_store_flag_mask, noce_try_cmove,
noce_try_cmove_arith, noce_try_minmax, noce_try_abs,
noce_try_sign_mask): Use end_ifcvt_sequence to factor common code.
2004-06-24 Jeff Law <law@redhat.com> 2004-06-24 Jeff Law <law@redhat.com>
* gimplify.c (gimplify_compound_lval): Reset TREE_SIDE_EFFECTS * gimplify.c (gimplify_compound_lval): Reset TREE_SIDE_EFFECTS
......
...@@ -699,14 +699,32 @@ noce_emit_move_insn (rtx x, rtx y) ...@@ -699,14 +699,32 @@ noce_emit_move_insn (rtx x, rtx y)
GET_MODE_BITSIZE (inmode)); GET_MODE_BITSIZE (inmode));
} }
/* Unshare sequence SEQ produced by if conversion. We care to mark /* Return sequence of instructions generated by if conversion. This
all arguments that may be shared with outer instruction stream. */ function calls end_sequence() to end the current stream, ensures
static void that are instructions are unshared, recognizable non-jump insns.
unshare_ifcvt_sequence (struct noce_if_info *if_info, rtx seq) On failure, this function returns a NULL_RTX. */
static rtx
end_ifcvt_sequence (struct noce_if_info *if_info)
{ {
rtx y;
rtx seq = get_insns ();
set_used_flags (if_info->x); set_used_flags (if_info->x);
set_used_flags (if_info->cond); set_used_flags (if_info->cond);
unshare_all_rtl_in_chain (seq); unshare_all_rtl_in_chain (seq);
end_sequence ();
if (seq_contains_jump (seq))
return NULL_RTX;
/* Make sure that all of the instructions emitted are recognizable.
As an excersise for the reader, build a general mechanism that
allows proper placement of required clobbers. */
for (y = seq; y ; y = NEXT_INSN (y))
if (recog_memoized (y) == -1)
return NULL_RTX;
return seq;
} }
/* Convert "if (a != b) x = a; else x = b" into "x = a" and /* Convert "if (a != b) x = a; else x = b" into "x = a" and
...@@ -742,16 +760,8 @@ noce_try_move (struct noce_if_info *if_info) ...@@ -742,16 +760,8 @@ noce_try_move (struct noce_if_info *if_info)
{ {
start_sequence (); start_sequence ();
noce_emit_move_insn (if_info->x, y); noce_emit_move_insn (if_info->x, y);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence ();
/* Make sure that all of the instructions emitted are
recognizable. As an excersise for the reader, build
a general mechanism that allows proper placement of
required clobbers. */
for (y = seq; y ; y = NEXT_INSN (y))
if (recog_memoized (y) == -1)
return FALSE; return FALSE;
emit_insn_before_setloc (seq, if_info->jump, emit_insn_before_setloc (seq, if_info->jump,
...@@ -795,11 +805,12 @@ noce_try_store_flag (struct noce_if_info *if_info) ...@@ -795,11 +805,12 @@ noce_try_store_flag (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (! seq)
end_sequence (); return FALSE;
emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
emit_insn_before_setloc (seq, if_info->jump,
INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
} }
else else
...@@ -926,15 +937,12 @@ noce_try_store_flag_constants (struct noce_if_info *if_info) ...@@ -926,15 +937,12 @@ noce_try_store_flag_constants (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence ();
if (seq_contains_jump (seq))
return FALSE; return FALSE;
emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a)); emit_insn_before_setloc (seq, if_info->jump,
INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
} }
...@@ -978,9 +986,10 @@ noce_try_addcc (struct noce_if_info *if_info) ...@@ -978,9 +986,10 @@ noce_try_addcc (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence (); return FALSE;
emit_insn_before_setloc (seq, if_info->jump, emit_insn_before_setloc (seq, if_info->jump,
INSN_LOCATOR (if_info->insn_a)); INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
...@@ -1017,16 +1026,12 @@ noce_try_addcc (struct noce_if_info *if_info) ...@@ -1017,16 +1026,12 @@ noce_try_addcc (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence ();
if (seq_contains_jump (seq))
return FALSE; return FALSE;
emit_insn_before_setloc (seq, if_info->jump, emit_insn_before_setloc (seq, if_info->jump,
INSN_LOCATOR (if_info->insn_a)); INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
} }
end_sequence (); end_sequence ();
...@@ -1071,16 +1076,12 @@ noce_try_store_flag_mask (struct noce_if_info *if_info) ...@@ -1071,16 +1076,12 @@ noce_try_store_flag_mask (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence ();
if (seq_contains_jump (seq))
return FALSE; return FALSE;
emit_insn_before_setloc (seq, if_info->jump, emit_insn_before_setloc (seq, if_info->jump,
INSN_LOCATOR (if_info->insn_a)); INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
} }
...@@ -1169,9 +1170,10 @@ noce_try_cmove (struct noce_if_info *if_info) ...@@ -1169,9 +1170,10 @@ noce_try_cmove (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence (); return FALSE;
emit_insn_before_setloc (seq, if_info->jump, emit_insn_before_setloc (seq, if_info->jump,
INSN_LOCATOR (if_info->insn_a)); INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
...@@ -1334,9 +1336,10 @@ noce_try_cmove_arith (struct noce_if_info *if_info) ...@@ -1334,9 +1336,10 @@ noce_try_cmove_arith (struct noce_if_info *if_info)
else if (target != x) else if (target != x)
noce_emit_move_insn (x, target); noce_emit_move_insn (x, target);
tmp = get_insns (); tmp = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, tmp); if (!tmp)
end_sequence (); return FALSE;
emit_insn_before_setloc (tmp, if_info->jump, INSN_LOCATOR (if_info->insn_a)); emit_insn_before_setloc (tmp, if_info->jump, INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
...@@ -1580,11 +1583,8 @@ noce_try_minmax (struct noce_if_info *if_info) ...@@ -1580,11 +1583,8 @@ noce_try_minmax (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence ();
if (seq_contains_jump (seq))
return FALSE; return FALSE;
emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a)); emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
...@@ -1698,11 +1698,8 @@ noce_try_abs (struct noce_if_info *if_info) ...@@ -1698,11 +1698,8 @@ noce_try_abs (struct noce_if_info *if_info)
if (target != if_info->x) if (target != if_info->x)
noce_emit_move_insn (if_info->x, target); noce_emit_move_insn (if_info->x, target);
seq = get_insns (); seq = end_ifcvt_sequence (if_info);
unshare_ifcvt_sequence (if_info, seq); if (!seq)
end_sequence ();
if (seq_contains_jump (seq))
return FALSE; return FALSE;
emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a)); emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
...@@ -1768,11 +1765,12 @@ noce_try_sign_mask (struct noce_if_info *if_info) ...@@ -1768,11 +1765,12 @@ noce_try_sign_mask (struct noce_if_info *if_info)
} }
noce_emit_move_insn (if_info->x, t); noce_emit_move_insn (if_info->x, t);
seq = get_insns ();
unshare_ifcvt_sequence (if_info, seq); seq = end_ifcvt_sequence (if_info);
end_sequence (); if (!seq)
emit_insn_before_setloc (seq, if_info->jump, return FALSE;
INSN_LOCATOR (if_info->insn_a));
emit_insn_before_setloc (seq, if_info->jump, INSN_LOCATOR (if_info->insn_a));
return TRUE; return TRUE;
} }
......
2004-06-25 Roger Sayle <roger@eyesopen.com>
PR middle-end/15825
* gcc.dg/pr15825-1.c: New test case.
2004-06-25 Richard Sandiford <rsandifo@redhat.com> 2004-06-25 Richard Sandiford <rsandifo@redhat.com>
* gcc.c-torture/execute/20040625-1.c: New test. * gcc.c-torture/execute/20040625-1.c: New test.
......
/* PR middle-end/15825 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
unsigned int foo(long long high, int unsigned_p)
{
int i;
if (high < 0)
if (!unsigned_p)
{
i = 1;
goto t;
}
i = 0;
t:
return i;
}
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