From: Kyrylo Tkachov <[email protected]>
After the subreg fallback, every path that reaches the rest of
noce_try_cond_arith has a conditional move in TARGET: the fallback either
returns, jumps to the failure label, or ends on a gcc_assert that TARGET is
non-null. Four later tests for a null TARGET are therefore dead, and one of
them makes the -1 costing look as though both candidates could fail, when only
the -1 candidate can.
State the invariant with a gcc_checking_assert and drop the dead tests. No
functional change.
gcc/ChangeLog:
* ifcvt.cc (noce_try_cond_arith): Assert that the conditional move
exists after the subreg fallback and drop the four dead tests for it.
Signed-off-by: Kyrylo Tkachov <[email protected]>
---
gcc/ifcvt.cc | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
index aea056cd95e..92c10c4957e 100644
--- a/gcc/ifcvt.cc
+++ b/gcc/ifcvt.cc
@@ -3587,6 +3587,10 @@ noce_try_cond_arith (struct noce_if_info *if_info)
gcc_assert (target);
}
+ /* Every path through the fallback above either returns or produces a
+ conditional move, so TARGET is non-null below. */
+ gcc_checking_assert (target);
+
if (outer_a)
{
XEXP (a, 1) = target;
@@ -3601,8 +3605,6 @@ noce_try_cond_arith (struct noce_if_info *if_info)
{
rtx_insn *seq0 = end_sequence ();
unsigned cost0 = seq_cost (seq0, if_info->speed_p);
- if (!target)
- cost0 = -1u;
/* Produce `cond ? z : -1`. */
rtx targetm1;
@@ -3615,9 +3617,6 @@ noce_try_cond_arith (struct noce_if_info *if_info)
unsigned costm1 = seq_cost (seqm1, if_info->speed_p);
if (!targetm1)
costm1 = -1u;
- /* If both fails, then there is no costing to be done. */
- if (!targetm1 && !target)
- return false;
/* If -1 is cheaper or the same cost to producing 0, then use that. */
if (costm1 <= cost0)
@@ -3632,8 +3631,7 @@ noce_try_cond_arith (struct noce_if_info *if_info)
}
end_sequence ();
}
- if (!target)
- return false;
+
/* For 0 the produce sequence is:
tmp = !cond ? y : 0
x = (y & z) | tmp */
@@ -3647,8 +3645,6 @@ noce_try_cond_arith (struct noce_if_info *if_info)
goto end_seq_n_fail;
goto success;
}
- if (!target)
- goto end_seq_n_fail;
target = expand_simple_binop (mode, op, a_op0, target, if_info->x, 0,
OPTAB_WIDEN);
--
2.50.1 (Apple Git-155)