Commit a0cbe71e by Jakub Jelinek Committed by Jakub Jelinek

re PR rtl-optimization/58668 (internal compiler error: in cond_exec_process_insns, at ifcvt.c:339)

	PR rtl-optimization/58668
	* cfgcleanup.c (flow_find_cross_jump): Don't count
	any jumps if dir_p is NULL.  Remove p1 variable, use active_insn_p
	to determine what is counted.
	(flow_find_head_matching_sequence): Use active_insn_p to determine
	what is counted.
	(try_head_merge_bb): Adjust for the flow_find_head_matching_sequence
	counting change.
	* ifcvt.c (count_bb_insns): Use active_insn_p && !JUMP_P to
	determine what is counted.

	* gcc.dg/pr58668.c: New test.

From-SVN: r206385
parent 41626746
2014-01-07 Jakub Jelinek <jakub@redhat.com> 2014-01-07 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/58668
* cfgcleanup.c (flow_find_cross_jump): Don't count
any jumps if dir_p is NULL. Remove p1 variable, use active_insn_p
to determine what is counted.
(flow_find_head_matching_sequence): Use active_insn_p to determine
what is counted.
(try_head_merge_bb): Adjust for the flow_find_head_matching_sequence
counting change.
* ifcvt.c (count_bb_insns): Use active_insn_p && !JUMP_P to
determine what is counted.
PR tree-optimization/59643 PR tree-optimization/59643
* tree-predcom.c (split_data_refs_to_components): If one dr is * tree-predcom.c (split_data_refs_to_components): If one dr is
read and one write, determine_offset fails and the write isn't read and one write, determine_offset fails and the write isn't
......
...@@ -1295,7 +1295,6 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2, ...@@ -1295,7 +1295,6 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
{ {
rtx i1, i2, last1, last2, afterlast1, afterlast2; rtx i1, i2, last1, last2, afterlast1, afterlast2;
int ninsns = 0; int ninsns = 0;
rtx p1;
enum replace_direction dir, last_dir, afterlast_dir; enum replace_direction dir, last_dir, afterlast_dir;
bool follow_fallthru, did_fallthru; bool follow_fallthru, did_fallthru;
...@@ -1323,8 +1322,9 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2, ...@@ -1323,8 +1322,9 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
|| (returnjump_p (i2) && !side_effects_p (PATTERN (i2)))) || (returnjump_p (i2) && !side_effects_p (PATTERN (i2))))
{ {
last2 = i2; last2 = i2;
/* Count everything except for unconditional jump as insn. */ /* Count everything except for unconditional jump as insn.
if (!simplejump_p (i2) && !returnjump_p (i2) && last1) Don't count any jumps if dir_p is NULL. */
if (!simplejump_p (i2) && !returnjump_p (i2) && last1 && dir_p)
ninsns++; ninsns++;
i2 = PREV_INSN (i2); i2 = PREV_INSN (i2);
} }
...@@ -1375,8 +1375,7 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2, ...@@ -1375,8 +1375,7 @@ flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2,
last1 = i1, last2 = i2; last1 = i1, last2 = i2;
afterlast_dir = last_dir; afterlast_dir = last_dir;
last_dir = dir; last_dir = dir;
p1 = PATTERN (i1); if (active_insn_p (i1))
if (!(GET_CODE (p1) == USE || GET_CODE (p1) == CLOBBER))
ninsns++; ninsns++;
} }
...@@ -1494,7 +1493,8 @@ flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1, ...@@ -1494,7 +1493,8 @@ flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1,
beforelast1 = last1, beforelast2 = last2; beforelast1 = last1, beforelast2 = last2;
last1 = i1, last2 = i2; last1 = i1, last2 = i2;
ninsns++; if (active_insn_p (i1))
ninsns++;
} }
if (i1 == BB_END (bb1) || i2 == BB_END (bb2) if (i1 == BB_END (bb1) || i2 == BB_END (bb2)
...@@ -2408,9 +2408,7 @@ try_head_merge_bb (basic_block bb) ...@@ -2408,9 +2408,7 @@ try_head_merge_bb (basic_block bb)
max_match--; max_match--;
if (max_match == 0) if (max_match == 0)
return false; return false;
do e0_last_head = prev_active_insn (e0_last_head);
e0_last_head = prev_real_insn (e0_last_head);
while (DEBUG_INSN_P (e0_last_head));
} }
if (max_match == 0) if (max_match == 0)
...@@ -2430,16 +2428,14 @@ try_head_merge_bb (basic_block bb) ...@@ -2430,16 +2428,14 @@ try_head_merge_bb (basic_block bb)
basic_block merge_bb = EDGE_SUCC (bb, ix)->dest; basic_block merge_bb = EDGE_SUCC (bb, ix)->dest;
rtx head = BB_HEAD (merge_bb); rtx head = BB_HEAD (merge_bb);
while (!NONDEBUG_INSN_P (head)) if (!active_insn_p (head))
head = NEXT_INSN (head); head = next_active_insn (head);
headptr[ix] = head; headptr[ix] = head;
currptr[ix] = head; currptr[ix] = head;
/* Compute the end point and live information */ /* Compute the end point and live information */
for (j = 1; j < max_match; j++) for (j = 1; j < max_match; j++)
do head = next_active_insn (head);
head = NEXT_INSN (head);
while (!NONDEBUG_INSN_P (head));
simulate_backwards_to_point (merge_bb, live, head); simulate_backwards_to_point (merge_bb, live, head);
IOR_REG_SET (live_union, live); IOR_REG_SET (live_union, live);
} }
......
...@@ -118,7 +118,7 @@ count_bb_insns (const_basic_block bb) ...@@ -118,7 +118,7 @@ count_bb_insns (const_basic_block bb)
while (1) while (1)
{ {
if (CALL_P (insn) || NONJUMP_INSN_P (insn)) if (active_insn_p (insn) && !JUMP_P (insn))
count++; count++;
if (insn == BB_END (bb)) if (insn == BB_END (bb))
......
2014-01-07 Jakub Jelinek <jakub@redhat.com> 2014-01-07 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/58668
* gcc.dg/pr58668.c: New test.
PR tree-optimization/59643 PR tree-optimization/59643
* gcc.dg/pr59643.c: New test. * gcc.dg/pr59643.c: New test.
* gcc.c-torture/execute/pr59643.c: New test. * gcc.c-torture/execute/pr59643.c: New test.
......
/* PR rtl-optimization/58668 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-mthumb" { target { { arm*-*-* } && arm_thumb2_ok } } } */
void *fn1 (void *);
void *fn2 (void *, const char *);
void fn3 (void *);
void fn4 (void *, int);
void *
test (void *x)
{
void *a, *b;
if (!(a = fn1 (x)))
return (void *) 0;
if (!(b = fn2 (a, "w")))
{
fn3 (a);
return (void *) 0;
}
fn3 (a);
fn4 (b, 1);
return b;
}
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