[Bug middle-end/88784] Middle end is missing some optimizations about unsigned

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri May 24 07:01:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88784

--- Comment #12 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Qi Feng from comment #11)
> 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}.

It isn't supposed to be done in original anyway. It does work in optimized
(even forwprop1) for me. Did you forget to pass -O? Did you look at some old
dump file?

(I think you could use ANY_INTEGRAL_TYPE_P, this seems valid for vectors)


More information about the Gcc-bugs mailing list