On Mon, 3 Mar 2014, Richard Biener wrote:

How do I restrict some subexpression to have
a single use?

This kind of restrictions come via the valueize() hook - simply
valueize to NULL_TREE to make the match fail (for example
SSA_NAME_OCCURS_IN_ABNORMAL_PHI could be made fail that way).

Shouldn't that single-use property depend more on the transformation and less on where it is called from? a+b-b -> a is always going to be a good idea (well, register pressure aside), even if a+b is used in many other places. But if you are using a*b elsewhere, turning a*b+c into FMA doesn't make so much sense.

Well, we can always call has_single_use on some @i if it is an SSA_NAME.

If I write a COND_EXPR matcher, could it generate code for phiopt as
well?

Not sure, what do you have in mind specifically?

fold-const.c has the equivalent of:
(define_match_and_simplify abs
  (COND_EXPR (LT_EXPR @0 zero_p) (NEGATE_EXPR @0) @0)
  (ABS_EXPR @0))

(it would help to be able to write LT_EXPR|LE_EXPR, maybe even to try automatically simplify(!a)?c:b for a?b:c) which works well on trees, but requires more complicated code in phiopt (same for min/max).

How do you handle a
transformation that currently tries to recursively fold something else and
does the main transformation only if that simplified?

And doesn't do the other folding (because it's not in the IL literally?)?
Similar to the cst without overflow case, by writing custom C code
and allowing that to signal failure.

I am not sure if it will be easy to write code that works for generic and gimple. I'll see...

--
Marc Glisse

Reply via email to