https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108625
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
we come from
t_2 = -x_1(D);
t1_3 = (unsigned char) t_2;
t2_4 = (unsigned char) t_2;
_5 = t1_3 + t2_4;
where
t_2 + t_2
"simplifies", but somehow the ! constraint isn't honored. We do
res_op->set_op (NOP_EXPR, type, 1);
{
tree _o1[2], _r1;
_o1[0] = captures[0];
_o1[1] = captures[1];
gimple_match_op tem_op (res_op->cond.any_else (), op,
TREE_TYPE (_o1[0]), _o1[0], _o1[1]);
tem_op.resimplify (lseq, valueize);
_r1 = maybe_push_res_to_seq (&tem_op, NULL);
if (!_r1) goto next_after_fail1082;
res_op->ops[0] = _r1;
so the intent is that the maybe_push_res_to_seq (..., NULL) will catch
not simplified operands of the (convert).
The issue is that we go through
/* A + (-B) -> A - B */
(simplify
(plus:c @0 (convert? (negate @1)))
/* Apply STRIP_NOPS on the negate. */
(if (tree_nop_conversion_p (type, TREE_TYPE (@1))
&& !TYPE_OVERFLOW_SANITIZED (type))
(with
{
tree t1 = type;
if (INTEGRAL_TYPE_P (type)
&& TYPE_OVERFLOW_WRAPS (type) != TYPE_OVERFLOW_WRAPS (TREE_TYPE (@1)))
t1 = TYPE_OVERFLOW_WRAPS (type) ? type : TREE_TYPE (@1);
}
(convert (minus (convert:t1 @0) (convert:t1 @1))))))
and
/* Basic strip-useless-type-conversions / strip_nops. */
(for cvt (convert view_convert float fix_trunc)
(simplify
(cvt @0)
(if ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@0)))
|| (GENERIC && type == TREE_TYPE (@0)))
@0)))
which defeats the check because the
tem_op.resimplify (lseq, valueize);
ends up with
_7 = t_2 - x_1(D);
in the 'lseq' and plain _7 in tem_op. We could fix this by using a
NULL lseq in the resimplification as well at the expense of not
catching some more complicated simplifications to "leafs" or
alternatively do a more complicated check for the force_leaf case,
checking the actual leaf and if SSA name, verify the definition is
not in 'lseq'.
I'm going to test the simpler NULL lseq to resimplify variant.