This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Slightly improve perf of SimplifySelectOps
Needs ReviewPublic

Authored by loladiro on Jan 18 2023, 2:49 PM.

Details

Reviewers
niravd
Summary

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.

[1] https://github.com/llvm/llvm-project/issues/60132

Diff Detail

Event Timeline

loladiro created this revision.Jan 18 2023, 2:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 2:49 PM
loladiro requested review of this revision.Jan 18 2023, 2:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 2:49 PM