On 11/23/21 3:46 AM, Giovanni Mascellani wrote:
Hi,
On 23/11/21 02:45, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
This depends on 220151.
It also clashes with 220153, though it's easy to fix that.
I am not particularly opposed to this patch, but what is the reason? In most (if not all) cases, if you replace a node and don't remove it, it will eventually be removed by DCE, so the result is going to be the same in the end (maybe processing will be a little slower, but I don't think that's a big problem).
Yes, although that requires you to run DCE afterwards. Which is extra work, that's not particularly necessary if you already know what needs to be deleted. It also means that if you're going to run an optimization pass in a loop you need to make sure there's a DCE pass in that loop.
There are some cases in which it is necessary to immediately remove the replaced node, because otherwise optimization enters an infinite loop. Since you introduced replace_and_remove_node I guess you already discovered that the hard way! :-P
But are there cases in which it is necessary to _not_ remove the replaced node? Because if there aren't, I would just always remove it as it happens now, which seems to me the simplest solution.
Patches 3 and 4 in this series reuse the replaced node. It's not *necessary* to do that, but it works, and saves the trouble of allocating a new one. I'm not opposed if there's a consensus of "don't do that", though.