[PATCH 1/2] Auto-generate maybe_fold_and/or_comparisons from match.pd
Richard Biener
rguenther@suse.de
Mon Sep 9 13:42:00 GMT 2019
On Mon, 9 Sep 2019, Martin Liška wrote:
> On 9/9/19 3:10 PM, Richard Biener wrote:
> > On Mon, 9 Sep 2019, Martin Liška wrote:
> >
> >> Hi.
> >>
> >> I'm sending slightly updated version of the patch where we
> >> need to properly select type in maybe_fold_comparisons_from_match_pd
> >> function for the created SSA_NAMEs. We can be called for a VECTOR_TYPE
> >> and so that we can't return a boolean_type_node.
> >>
> >> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> >>
> >> Ready to be installed?
> >
> > 2019-07-16 Li Jia He <helijia@linux.ibm.com>
> > Martin Liska <mliska@suse.cz>
> >
> > * gimple.h (gimple_init): Declare.
> > (gimple_size): Likewise.
> > * gimple.c (gimple_init): Remove static and inline restrictions.
> > (gimple_alloc): Only allocate memory and call gimple_init.
> > (gimple_size): Likewise.
> >
> > Likewise?
>
> Fixed.
>
> >
> > * tree-ssanames.c (init_ssa_name_imm_use): Use make_ssa_name_fn.
> > (make_ssa_name_fn): New.
> >
> > You didn't touch make_ssa_name_fn.
>
> Likewise here.
>
> >
> > Since we're needing another iteration:
> >
> > + /* Allocate gimple stmt1 on the stack. */
> > + gimple *stmt1 = (gimple *) XALLOCAVEC (char, gimple_size
> > (GIMPLE_ASSIGN, 2));
> >
> > You can use gassign *stmt1 here so all the gimple_assign_ fns below
> > get cheaper.
> >
> > + if (op.resimplify (NULL, follow_all_ssa_edges))
> > + {
> > + if (gimple_simplified_result_is_gimple_val (&op))
> > + {
> > + tree res = op.ops[0];
> > + switch (TREE_CODE (res))
> > + {
> > + case SSA_NAME:
> > + {
> > + gimple *def = SSA_NAME_DEF_STMT (res);
> >
> > you shouldn't expand SSA names here unless that SSA name is
> > exactly lhs1 or lhs2 from above. So
>
> Ah, got it.
>
> >
> > if (res == lhs1)
> > return build2 (...);
> > else if (res == lhs2)
> > return build2 (..);
> > else
> > return res;
> >
> > plus you miss the case where 'op' became a simplified comparison
> > in itself. So,
>
> Yes, that part is included in part 3. I'm going to send the updated patch
> 3 as well soon.
>
> >
> > if (op.code.is_tree_code ()
> > && TREE_CODE_CLASS ((enum tree_code)op.code) == tcc_comparison)
> > {
> > tree op0 = op.ops[0];
> > tree op1 = op.ops[1];
> > if (op0 == lhs1 || op0 == lhs2 || op1 == lhs1 || op1 == lhs2)
> > return NULL_TREE; /* not simple */
> > return build2 ((enum tree_code)op.code, op.type,
> > op0, op1);
> > }
> >
> > note you need not fold_ again. It's of course ugly that we
> > need to build a GENERIC tree here but that's the current interface
> > and thus OK at the moment.
>
> I see. But what I need is to insert newly created GIMPLE assignment to
> the provided gimple sequence (gsi), right?
There is no newly created GIMPLE?
Richard.
More information about the Gcc-patches
mailing list