This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix ifcvt (PR rtl-optimization/58668)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 19 Dec 2013 21:34:05 +0100
- Subject: Re: [PATCH] Fix ifcvt (PR rtl-optimization/58668)
- Authentication-results: sourceware.org; auth=none
- References: <20131218151736 dot GE892 at tucnak dot redhat dot com> <CABu31nPbW_2_5o9CyaSMTCq_tFrHqpdKMi8uFJkZLs9Q_G9GAw at mail dot gmail dot com> <20131219080240 dot GM892 at tucnak dot redhat dot com> <CABu31nOX6yCKjjAE9y_Qx2st-PT2V=BiyQOnG41Oqopd7c8BeA at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Dec 19, 2013 at 12:38:49PM +0100, Steven Bosscher wrote:
> >> Why not use active_insn_p instead of hand-checks for USE and CLOBBER insns?
> >
> > Because it brings in the JUMP_TABLE_DATA mess into the picture?
>
> Not as long as you look only between BB_HEAD and BB_END
> (JUMP_TABLE_DATA only appears outside basic blocks). AFAICT the code
> your patch touches only looks at insns contained in basic blocks.
So like this instead? Bootstrapped/regtested on x86_64-linux and
i686-linux. For 4.8 I'd still prefer the earlier patch though.
2013-12-18 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.
* gcc.dg/pr58668.c: New test.
--- gcc/ifcvt.c.jj 2013-12-19 16:20:32.849650410 +0100
+++ gcc/ifcvt.c 2013-12-19 17:28:28.544278601 +0100
@@ -118,7 +118,7 @@ count_bb_insns (const_basic_block bb)
while (1)
{
- if (CALL_P (insn) || NONJUMP_INSN_P (insn))
+ if (active_insn_p (insn) && !JUMP_P (insn))
count++;
if (insn == BB_END (bb))
--- gcc/cfgcleanup.c.jj 2013-12-19 09:03:05.600983104 +0100
+++ gcc/cfgcleanup.c 2013-12-19 17:27:20.808625980 +0100
@@ -1295,7 +1295,6 @@ flow_find_cross_jump (basic_block bb1, b
{
rtx i1, i2, last1, last2, afterlast1, afterlast2;
int ninsns = 0;
- rtx p1;
enum replace_direction dir, last_dir, afterlast_dir;
bool follow_fallthru, did_fallthru;
@@ -1323,8 +1322,9 @@ flow_find_cross_jump (basic_block bb1, b
|| (returnjump_p (i2) && !side_effects_p (PATTERN (i2))))
{
last2 = i2;
- /* Count everything except for unconditional jump as insn. */
- if (!simplejump_p (i2) && !returnjump_p (i2) && last1)
+ /* Count everything except for unconditional jump as insn.
+ Don't count any jumps if dir_p is NULL. */
+ if (!simplejump_p (i2) && !returnjump_p (i2) && last1 && dir_p)
ninsns++;
i2 = PREV_INSN (i2);
}
@@ -1375,8 +1375,7 @@ flow_find_cross_jump (basic_block bb1, b
last1 = i1, last2 = i2;
afterlast_dir = last_dir;
last_dir = dir;
- p1 = PATTERN (i1);
- if (!(GET_CODE (p1) == USE || GET_CODE (p1) == CLOBBER))
+ if (active_insn_p (i1))
ninsns++;
}
@@ -1494,7 +1493,8 @@ flow_find_head_matching_sequence (basic_
beforelast1 = last1, beforelast2 = last2;
last1 = i1, last2 = i2;
- ninsns++;
+ if (active_insn_p (i1))
+ ninsns++;
}
if (i1 == BB_END (bb1) || i2 == BB_END (bb2)
@@ -2408,9 +2408,7 @@ try_head_merge_bb (basic_block bb)
max_match--;
if (max_match == 0)
return false;
- do
- e0_last_head = prev_real_insn (e0_last_head);
- while (DEBUG_INSN_P (e0_last_head));
+ e0_last_head = prev_active_insn (e0_last_head);
}
if (max_match == 0)
@@ -2430,16 +2428,14 @@ try_head_merge_bb (basic_block bb)
basic_block merge_bb = EDGE_SUCC (bb, ix)->dest;
rtx head = BB_HEAD (merge_bb);
- while (!NONDEBUG_INSN_P (head))
- head = NEXT_INSN (head);
+ if (!active_insn_p (head))
+ head = next_active_insn (head);
headptr[ix] = head;
currptr[ix] = head;
/* Compute the end point and live information */
for (j = 1; j < max_match; j++)
- do
- head = NEXT_INSN (head);
- while (!NONDEBUG_INSN_P (head));
+ head = next_active_insn (head);
simulate_backwards_to_point (merge_bb, live, head);
IOR_REG_SET (live_union, live);
}
--- gcc/testsuite/gcc.dg/pr58668.c.jj 2013-12-19 17:24:13.239587709 +0100
+++ gcc/testsuite/gcc.dg/pr58668.c 2013-12-19 17:24:13.239587709 +0100
@@ -0,0 +1,25 @@
+/* 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;
+}
Jakub