Adds a check that detects 2D array traversals where the array is traversed column wise instead of row wise.
These patterns harm cache performance as well as prevent auto-vectorisation opportunities.
Details
- Reviewers
alexfh aaron.ballman LegalizeAdulthood
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp | ||
---|---|---|
60 | I think will be reasonable to check for += and -=. | |
clang-tools-extra/docs/ReleaseNotes.rst | ||
121 | Please highlight for with double back-ticks. Same in documentation. | |
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-array-traversal.rst | ||
16 | Excessive newline. | |
27 | Excessive newline. |
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp | ||
---|---|---|
64 | Thoughts on this, prefetchers are often able to detect strided access so is forcing increment to be 1 removing potential functionality. | |
92 | Any ideas on a nicer way to say this? I feel like this message isn't as descriptive as I'd like, and non-native English speakers could struggle to understand it. |
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.cpp | ||
---|---|---|
64 | Theoretically index changes may be other than 1. For example, in some electronic simulation each block/device store matrix indexes to contribute (but sparse, not dense, matrix is used). It'll be good idea to look on BLAS and LAPACK (through both are written in Fortran). |
Except for a couple nits, LGTM.
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.h | ||
---|---|---|
26–27 | If you're not doing anything different, I believe you can just do Also, shouldn't you be explicitly overriding the d'tor? |
clang-tools-extra/clang-tidy/performance/InefficientArrayTraversalCheck.h | ||
---|---|---|
26–27 | No need to explicitly override the d'tor |
Simplify check logic to only detect loop inits with 0 and incriment with 1.
Functionality can be introduced with later patches.
If you're not doing anything different, I believe you can just do
using ClangTidyCheck::ClangTidyCheck;
Also, shouldn't you be explicitly overriding the d'tor?
~InefficientArrayTraversalCheck() override = default;