Guards: Improve performance for phi nodes with many incoming constant values.#20569
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves performance for phi nodes with many incoming constant values by optimizing the uniqueValue predicate. It replaces an expensive forex operation with more efficient counting operations, leveraging the fact that all possible values are singletons where disjointness is equivalent to inequality.
- Replaced
forexwithdisjointValuescheck using twostrictcountoperations - Added documentation clarifying that the predicate is restricted to constant singleton values
- Improved performance for cases like neovim with many incoming constant values
|
Thanks a lot, Schack! This looks really good locally 🎉 I'm doing a DCA on #20485 with this PR on top of it which should cover C/C++, at least. Do you want to do a DCA for Java as well? |
Might as well. Triggered now. |
|
Looks like Neovim is happy now 🎉 Here is the performance impact of #20485 with this PR on top: |
|
The CPP CI failures are unrelated and would be fixed by merging in |
This should improve performance significantly for neovim. All the possible values that are considered are singletons, so disjointness is equivalent to inequality - this means that we can replace the expensive
forexwith two counts. See also #20485 (comment)