In [1], I noted an issue with SimplifySelectOps' performance.
This revision contains a few misc changes that improve
performance slightly by avoiding unnecessary walks, but
because the overall problem reported in this issue is algorithmic,
the end-to-end perf impact is minimal (at most 3x faster or so).
In particular, this change:
- Removes redundant ->isPredecessorOf check that is covered more performantly by the subsequent call to hasPredecessorHelper.
- Changes the backwards search barrier from TheSelect (which, contrary to the comment above, should always be a *successor* of the nodes in question). Instead, we use the chain operand of the loads. One of the legality conditions is that both loads have the same chain operand, so this is guaranteed to be a predecessor of at least the loads, and cuts off search through it.
- Corrects the argument checked in hasAnyUseOfValue. According to the comment, this was supposed to check the chain operand of the load. However, it instead checks the value operand is thus trivially true, because we know that the value is used by TheSelect. I think the comment is correct here. We already know that TheSelect is the only user of the loads' values. As a result, the only path to the condition would have to go through the chain operand, so if that is unused, we can avoid performing the search.