This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Extend CSE to use constant anchors


> Here we call it with a general expression so it needs to prune the table
> from expressions referring to stale values of the registers mentioned in
> the new expression.  Previously in cse_insn we invoked it with a register
> expression so it didn't the prune the table.

You're right, I forgot about this strategy.

> I could have used mention_regs here but I prefer the more widely used API
> of insert_regs/insert.
>
> I did however remove the call to rehash_using_reg.

Yes, but the second call to HASH is useless too, so I'd just do:

+  anchor_exp = GEN_INT (anchor);
+  hash = HASH (anchor_exp, mode);
+  elt = lookup (anchor_exp, hash, mode);
+  if (!elt)
+    elt = insert (anchor_exp, NULL, hash, mode);
+
+  /* REG has just been inserted and the hash codes recomputed.  */
+  exp = plus_constant (reg, offs);
+  mention_regs (exp);
+  hash = HASH (exp, mode);

> Does the updated comment answer your question?  The second testcase is an
> example for this.:
>
>   /* Use the cost of the register rather than the whole expression.
>      When looking up constant anchors we will further offset the
>      corresponding expression therefore it does not make sense to
>      prefer REGs over reg-immediate additions.  Prefer instead the
>      oldest expression.  Also don't prefer pseudos over hard regs so
>      that we derive constants in argument registers from other
>      argument registers rather than from the original pseudo that
>      was used to synthesize the constant.  */

OK.

> This is BTW how exp_equiv_p is used in other places so I don't think it
> requires a comment.

OK.

> I think you're referring to how related values are updated in insert.  If
> yes, then I don't think that's similar.  insert() is also used in
> merge_equiv_classes to merge two equivalence classes.  In this case, for
> related values you need to update the related_value link in the new entry
> so you *have to* do the processing in insert, which is not the case for
> constant anchors.
>
> Also note that because it's in insert, which can be called more than once
> for an expression, you have to do a lookup before you insert the related
> value. We can save this lookup for constant anchors.

OK.

> Here is the updated patch.  Let me know if you want me to make further
> modifications or my answers are satisfactory.

OK for mainline with the additional simplification in insert_const_anchor.

Thanks for your patience.

-- 
Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]