https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88784
--- Comment #11 from Qi Feng <ffengqi at gcc dot gnu.org> ---
I tried 2 patterns for the following test
/* 1. x > y && x != 0 --> x > y */
/* 2. y < x && x != 0 --> y < x */
/* 3. x != 0 && x > y --> x > y */
/* 4. x != 0 && y < x --> y < x */
_Bool f1 (unsigned x, unsigned y)
{
return x > y && x != 0;
}
_Bool f2 (unsigned x, unsigned y)
{
return y < x && x != 0;
}
_Bool f3 (unsigned x, unsigned y)
{
return x != 0 && x > y;
}
_Bool f4 (unsigned x, unsigned y)
{
return x != 0 && y < x;
}
The first one is
(for and (truth_and bit_and)
(simplify
(and:c (gt:c@2 @0 @1) (ne @0 integer_zerop))
(if (INTEGRAL_TYPE_P (TREE_TYPE(@0)) && TYPE_UNSIGNED (TREE_TYPE(@0))
&& INTEGRAL_TYPE_P (TREE_TYPE(@1)) && TYPE_UNSIGNED (TREE_TYPE(@1)))
@2)))
The transformations did not happen as I checked the dump files of
-fdump-tree-{original,optimized}.
And the second one is
(simplify
(truth_andif:C (gt:c@2 @0 @1) (ne @0 integer_zerop))
(if (INTEGRAL_TYPE_P (TREE_TYPE(@0)) && TYPE_UNSIGNED (TREE_TYPE(@0))
&& INTEGRAL_TYPE_P (TREE_TYPE(@1)) && TYPE_UNSIGNED (TREE_TYPE(@1)))
@2))
The transformations did happen for all the 4 functions. And the dump of
-fdump-tree-original showes they already happened, so I guess the pattern is
matched before the process get to GIMPLE.