http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59660
Bug ID: 59660
Summary: We fail to optimize common boolean checks pre-inlining
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
We fail to inline the following function from graphite-poly.h:
/* Determine whether CHREC is an affine evolution function or not. */
static inline bool
evolution_function_is_affine_p (const_tree chrec)
{
return chrec
&& TREE_CODE (chrec) == POLYNOMIAL_CHREC
&& evolution_function_is_invariant_p (CHREC_RIGHT (chrec),
CHREC_VARIABLE (chrec))
&& (TREE_CODE (CHREC_RIGHT (chrec)) != POLYNOMIAL_CHREC
|| evolution_function_is_affine_p (CHREC_RIGHT (chrec)));
}
It is tail recursive, but the recursion is easy to remove and handled by late
tail recursion pass (post inlining). Pre-inlining we stop at:
<bb 6>:
_15 = evolution_function_is_affine_p (_12);
if (_15 != 0)
goto <bb 7>;
else
goto <bb 8>;
<bb 7>:
<bb 8>:
# iftmp.121_1 = PHI <1(7), 0(3), 0(2), 0(6), 0(4), 1(5)>
return iftmp.121_1;
The conditional here is autogenerated by the boolean expression but is
pointless. Phiopt gets it into:
<bb 6>:
_15 = evolution_function_is_affine_p (_12);
<bb 7>:
# iftmp.121_1 = PHI <1(5), 0(3), 0(2), _15(6), 0(4)>
return iftmp.121_1;
This seems rather common pattern suggesting that perhaps we may phiopt
pre-inline or do the same trick in one of existing early opts?