C++: Optimise quadratic code in PreprocessorBranchDirective#1335
C++: Optimise quadratic code in PreprocessorBranchDirective#1335geoffw0 merged 1 commit intogithub:masterfrom edoardopirovano:optimise-preprocessor
Conversation
|
I wonder if this should not be re-written using |
|
Do we have any examples of projects where this code is performing poorly? It's already been through a few rounds of optimization in recent years, though I can see that if there are many |
|
I have no examples of projects where this currently performs badly. However, the current performance relies on the fact that the CSE pass of the optimiser pulls out part of the code that is shared between the body of the not and the conjunction outside. A future optimiser change could break this (indeed there is one in development that would), and the change here ensures this won't be the case. |
We don't connect Together with the fact preprocessor directives are guaranteed to be on a unique source line (I think without exception, but please correct me if I'm wrong on this) that makes |
|
I just ran some tests of I also prefer the new code.
What does CSE stand for? |
|
Sorry, CSE stands for Common Subexpression Elimination. It pulls out expressions that are used in multiple places to their own predicates, in this particular case the |
This change makes the quadratic code for finding the next
PreprocessorBranchDirectiveingetNextlinear by pulling out the index computation to a new predicategetIndexInBranch.