https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123109
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #0)
> This was kinda of noticed on accident via PR 123107.
> But currently fold simplifies `(signed >> (sizeof(signed)*8-1)) != 0` into
> `signed < 0` but match does not do it.
>
> ```
> /* Fold (X >> C) != 0 into X < 0 if C is one less than the width
> of X. Similarly fold (X >> C) == 0 into X >= 0. */
> if (TREE_CODE (arg0) == RSHIFT_EXPR
> && integer_zerop (arg1)
> && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
> {
> tree arg00 = TREE_OPERAND (arg0, 0);
> tree arg01 = TREE_OPERAND (arg0, 1);
> tree itype = TREE_TYPE (arg00);
> if (wi::to_wide (arg01) == element_precision (itype) - 1)
> {
> if (TYPE_UNSIGNED (itype))
> {
> itype = signed_type_for (itype);
> arg00 = fold_convert_loc (loc, itype, arg00);
> }
> return fold_build2_loc (loc, code == EQ_EXPR ? GE_EXPR :
> LT_EXPR,
> type, arg00, build_zero_cst (itype));
> }
> }
> ```
>
> Note for match, we need to expand_vec_cmp_expr_p (I think that is the
> correct thing to check).
it should be expand_vec_cmp_expr_p if canonicalize_math_after_vectorization_p.
If !canonicalize_math_after_vectorization_p we shouldn't turn a supported
compare to an unsupported one but unsupported -> unsupported is OK.