This is an archive of the discontinued LLVM Phabricator instance.

Bump coalescing limit
ClosedPublic

Authored by MatzeB on May 19 2023, 1:17 PM.

Details

Summary

This bumps the "large-interval-freq-threshold" limit in the register coalescer to 256. The limit was introduced in https://reviews.llvm.org/D59143 without much justify for the particular value "100", so I hope bumping it is ok.

This change is motivated by bad codegen for the popular crc32c algorithm; the code is often based/copied from this implementation: https://github.com/htot/crc32c/blob/master/crc32c/crc32intelc.cc which uses a duffs-device pattern with 128 switch-cases. There are examples in RocksDB (https://github.com/facebook/rocksdb/blob/main/util/crc32c.cc) and Folly (https://github.com/facebook/folly/blob/main/folly/hash/detail/Crc32cDetail.cpp) which are important use cases for us.

Diff Detail

Event Timeline

MatzeB created this revision.May 19 2023, 1:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2023, 1:17 PM
Herald added subscribers: modimo, wenlei, tpr and 2 others. · View Herald Transcript
MatzeB requested review of this revision.May 19 2023, 1:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2023, 1:17 PM

FWIW I noticed that fixing this dramatically improves IPC and instructions executed, but does not actually affect benchmark runtimes. For my microbenchmark.

Before:

5,581,342,454      cycles                    #    3.288 GHz                      (50.02%)
11,940,550,021      instructions              #    2.14  insn per cycle           (50.05%)

After:

5,595,396,911      cycles                    #    3.264 GHz                      (50.01%)
6,809,294,177      instructions              #    1.22  insn per cycle           (50.06%)

so this isn't as critical as I initially thought, but I also don't think it hurt anything and improves code size.

MatzeB edited the summary of this revision. (Show Details)May 19 2023, 1:31 PM
MatzeB edited the summary of this revision. (Show Details)

I did not notice any change in compiletimes but then again the projects I have here typically don't even hit the 100 limit. Maybe someone using SpeculativeLoadHardening could confirm or report back in case of trouble?

qcolombet accepted this revision.May 22 2023, 2:26 AM

Hi @MatzeB,

Given what you observed and this limit is pretty much never hit in practice, I'm fine with bumping it.

If people come back complaining with compile time, we can lower it again.

Cheers,
-Quentin

This revision is now accepted and ready to land.May 22 2023, 2:26 AM
This revision was landed with ongoing or failed builds.May 24 2023, 9:15 AM
Closed by commit rG7ac63f004ca6: Bump coalescing limit (authored by MatzeB). · Explain Why
This revision was automatically updated to reflect the committed changes.