This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH GCC8][17/33]Treat complex cand step as invriant expression
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bin Cheng <Bin dot Cheng at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Wed, 3 May 2017 15:43:05 +0200
- Subject: Re: [PATCH GCC8][17/33]Treat complex cand step as invriant expression
- Authentication-results: sourceware.org; auth=none
- References: <VI1PR0802MB2176BEAC53A37DCA039C0137E7190@VI1PR0802MB2176.eurprd08.prod.outlook.com>
On Tue, Apr 18, 2017 at 12:46 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> We generally need to compute cand step in loop preheader and use it in loop body.
> Unless it's an SSA_NAME of constant integer, an invariant expression is needed.
I'm confused as to what this patch does. Comments talk about "Handle step as"
but then we print "Depend on inv...". And we share bitmaps, well it seems
+ find_inv_vars (data, &step, &cand->inv_vars);
+
+ iv_inv_expr_ent *inv_expr = get_loop_invariant_expr (data, step);
+ /* Share bitmap between inv_vars and inv_exprs for cand. */
+ if (inv_expr != NULL)
+ {
+ cand->inv_exprs = cand->inv_vars;
+ cand->inv_vars = NULL;
+ if (cand->inv_exprs)
+ bitmap_clear (cand->inv_exprs);
+ else
+ cand->inv_exprs = BITMAP_ALLOC (NULL);
+
+ bitmap_set_bit (cand->inv_exprs, inv_expr->id);
just shares the bitmap allocation (and leaks cand->inv_exprs?).
Note that generally it might be cheaper to use bitmap_head instead of
bitmap in the various structures (and then bitmap_initialize ()), this
saves one indirection.
Anyway, the relation between inv_vars and inv_exprs is what confuses me.
Maybe it's the same as for cost_pair? invariants vs. loop invariants?
whatever that means...
That is, can you expand the comments in cost_pair / iv_cand for inv_vars
vs. inv_exprs, esp what "invariant" actually means?
Thanks,
Richard.
> Thanks,
> bin
>
> 2017-04-11 Bin Cheng <bin.cheng@arm.com>
>
> * tree-ssa-loop-ivopts.c (struct iv_cand): New field inv_exprs.
> (dump_cand): Support iv_cand.inv_exprs.
> (add_candidate_1): Record invariant exprs in iv_cand.inv_exprs
> for candidates.
> (iv_ca_set_no_cp, iv_ca_set_cp, free_loop_data): Support
> iv_cand.inv_exprs.