[llvm] [CodeGen] Restore MachineBlockPlacement block ordering (PR #99351)
John Brawn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 09:45:22 PDT 2024
john-brawn-arm wrote:
I've changed this to sort the blocks by block number in collectLoopBlockSet. Testing on this program:
```
#define LOOP(X) if (x) goto label##X; for (i = 0; i < n; i++) { if (x) { label##X: x += 1; } else { x -= 1; } }
#define LOOP10(X) for (int j = 0; j < n; j++) { LOOP(X##0) LOOP(X##1) LOOP(X##2) LOOP(X##3) LOOP(X##4) LOOP(X##5) LOOP(X##6) LOOP(X##7) LOOP(X##8) LOOP(X##9) }
#define LOOP100(X) for (int k = 0; k < n; k++) { LOOP10(X##0) LOOP10(X##1) LOOP10(X##2) LOOP10(X##3) LOOP10(X##4) LOOP10(X##5) LOOP10(X##6) LOOP10(X##7) LOOP10(X##8) LOOP10(X##9) }
#define LOOP1000(X) LOOP100(X##0) LOOP100(X##1) LOOP100(X##2) LOOP100(X##3) LOOP100(X##4) LOOP100(X##5) LOOP100(X##6) LOOP100(X##7) LOOP100(X##8) LOOP100(X##9)
#define LOOP10000(X) LOOP1000(X##0) LOOP1000(X##1) LOOP1000(X##2) LOOP1000(X##3) LOOP1000(X##4) LOOP1000(X##5) LOOP1000(X##6) LOOP1000(X##7) LOOP1000(X##8) LOOP1000(X##9)
volatile int x, n;
void test() {
int i;
LOOP10000(0)
}
```
Using ``-stop-before=block-placement`` then running ```perf stat -e task-clock llc -run-pass=block-placement`` the average time in milliseconds over 10 runs is:
* Current: 3160
* With this patch: 3169
* Replace BlockFilterSet with a sorted std::set everywhere, not just in collectLoopBlockSet: 3247
* Original version: 3835
* #91843 reverted: 3823
https://github.com/llvm/llvm-project/pull/99351
More information about the llvm-commits
mailing list