On Mon, Aug 16, 2021 at 8:48 PM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Mon, Aug 16, 2021 at 9:15 AM Jirui Wu via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > Hi all,
> >
> > This patch generates FRINTZ instruction to optimize type casts.
> >
> > The changes in this patch covers:
> > * Opimization of a FIX_TRUNC_EXPR cast inside a FLOAT_EXPR using IFN_TRUNC.
> > * Change of corresponding test cases.
> >
> > Regtested on aarch64-none-linux-gnu and no issues.
> >
> > Ok for master? If OK can it be committed for me, I have no commit rights.
>
> Is there a reason why you are doing the transformation manually inside
> forwprop rather than handling it inside match.pd?
> Also can't this only be done for -ffast-math case?

You definitely have to look at the intermediate type - that could be a uint8_t
or even a boolean type.  So unless the intermediate type can represent
all float values optimizing to trunc() is invalid.  Also if you emit
IFN_TRUNC you have to make sure there's target support - we don't
emit calls to a library trunc() from an internal function call (and we wouldn't
want to optimize it that way).

Richard.

>
> Thanks,
> Andrew Pinski
>
> >
> > Thanks,
> > Jirui
> >
> > gcc/ChangeLog:
> >
> >         * tree-ssa-forwprop.c (pass_forwprop::execute): Optimize with 
> > frintz.
> >
> >
> > gcc/testsuite/ChangeLog:
> >
> >         * gcc.target/aarch64/fix_trunc1.c: Update to new expectation.

Reply via email to