On Tue, Jun 1, 2021 at 6:17 PM Marc Glisse <marc.gli...@inria.fr> wrote:
>
> On Tue, 1 Jun 2021, Hongtao Liu via Gcc-patches wrote:
>
> > Hi:
> >  This patch is about to simplify (view_convert:type ~a) < 0 to
> > (view_convert:type a) >= 0 when type is signed integer. Similar for
> > (view_convert:type ~a) >= 0.
> >  Bootstrapped and regtested on x86_64-linux-gnu{-m32,}.
> >  Ok for the trunk?
> >
> > gcc/ChangeLog:
> >
> >        PR middle-end/100738
> >        * match.pd ((view_convert ~a) < 0 --> (view_convert a) >= 0,
> >        (view_convert ~a) >= 0 --> (view_convert a) < 0): New GIMPLE
> >        simplification.
>
> We already have
>
> /* Fold ~X op C as X op' ~C, where op' is the swapped comparison.  */
> (for cmp (simple_comparison)
>       scmp (swapped_simple_comparison)
>   (simplify
>    (cmp (bit_not@2 @0) CONSTANT_CLASS_P@1)
>    (if (single_use (@2)
>         && (TREE_CODE (@1) == INTEGER_CST || TREE_CODE (@1) == VECTOR_CST))
>     (scmp @0 (bit_not @1)))))
>
> Would it make sense to try and generalize it a bit, say with
>
> (cmp (nop_convert1? (bit_not @0)) CONSTANT_CLASS_P)
>
> (scmp (view_convert:XXX @0) (bit_not @1))
>
Thanks for your advice, it looks great.
And can I use *view_convert1?* instead of *nop_convert1?* here,
because the original case is view_convert, and nop_convert would fail
to simplify the case.
> (I still believe that it is a bad idea that SSA_NAMEs are strongly typed,
> encoding the type in operations would be more convenient, but I think the
> time for that choice has long gone)
>
> --
> Marc Glisse



-- 
BR,
Hongtao

Reply via email to