[PATCH] D44700: [GlobalISel] Improving InstructionSelect's performance by reducing MatchTable

Roman Tereshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 18 20:41:38 PDT 2018


rtereshin added a comment.

I've split this patch up into an initial and rather large mostly NFC commit that does necessary preparation work and refactoring, and a following series of small patches introducing a specific optimization. The relative performance impact of each commit could be seen here:

**Release build, assertions off, llc sqlite3.bc -mtriple aarch64-- -O0 -time-passes -time-compilations=5**

|                    | Baseline         | Main Perf Patch: NFC + not checking topology first + moving reg bank checks to the end |                  | + Removing redundant num operands and nested def operands checks |                  | + Sorting first level by opcodes and num operands |                  | + Switching over opcodes |                  | + Second level grouping |                  | + Moving type checks forward |                  | + Sorting second level by root LLT |                  | + Maximizing # of Group's common conditions |                  | + Switching over LLTs |                  | + Moving Reg Bank Checks forward |                  | + Dropping redundant type checks |                  |                                  |                  |
| ------------------ | ---------------- | -------------------------------------------------------------------------------------- | ---------------- | ---------------------------------------------------------------- | ---------------- | ------------------------------------------------- | ---------------- | ------------------------ | ---------------- | ----------------------- | ---------------- | ---------------------------- | ---------------- | ---------------------------------- | ---------------- | ------------------------------------------- | ---------------- | --------------------- | ---------------- | -------------------------------- | ---------------- | -------------------------------- | ---------------- | -------------------------------- | ---------------- |
|                    |                  | seconds                                                                                | diff vs Baseline | seconds                                                          | diff vs Baseline | seconds                                           | diff vs previous | seconds                  | diff vs previous | seconds                 | diff vs previous | seconds                      | diff vs previous | seconds                            | diff vs previous | seconds                                     | diff vs previous | seconds               | diff vs previous | seconds                          | diff vs previous | seconds                          | diff vs previous |                                  |                  |
| Instruction Select | 0.9495           | 0.9727                                                                                 |                  | 0.9178                                                           |                  | 0.7517                                            |                  | 0.6048                   |                  | 0.5215                  |                  | 0.4824                       |                  | 0.3776                             |                  | 0.3762                                      |                  | 0.3506                |                  | 0.3428                           |                  | 0.3444                           |                  |                                  |                  |
|                    | 0.9469           | 0.9740                                                                                 |                  | 0.9168                                                           |                  | 0.7506                                            |                  | 0.6021                   |                  | 0.5220                  |                  | 0.4829                       |                  | 0.3767                             |                  | 0.3765                                      |                  | 0.3505                |                  | 0.3428                           |                  | 0.3443                           |                  |                                  |                  |
|                    | 0.9503           | 0.9720                                                                                 |                  | 0.9196                                                           |                  | 0.7557                                            |                  | 0.6055                   |                  | 0.5203                  |                  | 0.4822                       |                  | 0.3760                             |                  | 0.3758                                      |                  | 0.3502                |                  | 0.3434                           |                  | 0.3445                           |                  |                                  |                  |
| Min                | 0.947            | 0.972                                                                                  | 2.7%             | 0.917                                                            | -3.2%            | 0.751                                             | -18.1%           | 0.602                    | -19.8%           | 0.520                   | -13.6%           | 0.482                        | -7.3%            | 0.376                              | -22.0%           | 0.376                                       | -0.1%            | 0.350                 | -6.8%            | 0.343                            | -2.1%            | 0.344                            | 0.4%             |                                  |                  |
| Avg                | 0.949            | 0.973                                                                                  | 2.5%             | 0.918                                                            | -3.2%            | 0.753                                             | -18.0%           | 0.604                    | -19.7%           | 0.521                   | -13.7%           | 0.483                        | -7.4%            | 0.377                              | -21.9%           | 0.376                                       | -0.2%            | 0.350                 | -6.8%            | 0.343                            | -2.1%            | 0.344                            | 0.4%             |                                  |                  |
| Err                | 0.4%             | 0.2%                                                                                   |                  | 0.3%                                                             |                  | 0.7%                                              |                  | 0.6%                     |                  | 0.3%                    |                  | 0.1%                         |                  | 0.4%                               |                  | 0.2%                                        |                  | 0.1%                  |                  | 0.2%                             |                  | 0.1%                             |                  |                                  |                  |
|                    |                  |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  |                                  |                  |                                  |                  |
|                    |                  |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | + Making get type faster         |                  | + Dropping redundant type checks |                  |
|                    | diff vs Baseline |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | seconds                          | diff vs previous | seconds                          | diff vs previous |
|                    |                  |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | 0.3264                           |                  | 0.3266                           |                  |
|                    |                  |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | 0.3263                           |                  | 0.3264                           |                  |
|                    |                  |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | 0.3266                           |                  | 0.3277                           |                  |
| Min                | -65.5%           |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | 0.326                            | -4.8%            | 0.326                            | 0.0%             |
| Avg                | -65.6%           |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  | 0.326                            | -4.8%            | 0.327                            | 0.1%             |
| Err                | 0.1%             |                                                                                        |                  |                                                                  |                  |                                                   |                  |                          |                  |                         |                  |                              |                  |                                    |                  |                                             |                  |                       |                  |                                  |                  |                                  |                  | 0.4%                             |                  |
|

//Making get type faster// refers to https://reviews.llvm.org/D46809

//Dropping redundant type checks// has been closely investigated by dumping full traces of opcodes executed by the selector for sqlite3 amalgamation: the traces are identical down to extra type checks and additional nesting levels. The negative performance impact (though, nearly indistinguishable from error) is quite surprising. Especially the fact that making type checks faster brings noticeable improvement, while //removing them altogether// does not. The only theory I have is that checking types on all consecutive operands keeps something important hot in cache, while not checking them / checking in a non-local way gets important data evicted.

I'm not planning on committing that patch yet.


Repository:
  rL LLVM

https://reviews.llvm.org/D44700





More information about the llvm-commits mailing list