This is the mail archive of the
mailing list for the GCC project.
Re: fold() can't fold simple expressions?
On 09/14/2016 01:29 PM, Richard Biener wrote:
At a particular site we're going to have an expression where we want to
evaluate the operands (either to a constant or symbolically).
It's what match-and-simplify does as well.
I question the need to build GENERIC here though. M-a-s happily gets you a simplified expression as sequence of GIMPLE statements. (But does not yet provide a way to build a simplified GENERIC expression from GIMPLE IL)
For each operand in the expression we recursively raise the query "what
is this operand". THe result (potentially another expression) gets
substituted in for the operand and the process continues recursively.
Recursion stops when you get a constant or when you've walked back "too
far" or the expression gets "too complex".
Once you get something like (x+y)+z you're no longer gimple. But we
need to store that expression in some form.
That could be expressed as a vector of operators/operands. It could be
expressed as a generic tree. Whatever. Generic trees as a reasonably
natural way to store the expression as its built, but fold() those
arbitrary expressions doesn't work. m-a-s may be the answer here, I
haven't really thought about it yet.