llvm-project
llvm-project copied to clipboard
[DAGCombiner] Compile time blow up after enqueuing additional TokenFactor-s
Commit in question:
commit d6351340bb9bf7703fb79629efdba5886d434694
Date: Wed Mar 13 17:07:09 2019 +0000
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
SDValue DAGCombiner::visitTokenFactor(SDNode *N) {
...
// If the sole user is a token factor, we should make sure we have a
// chance to merge them together. This prevents TF chains from inhibiting
// optimizations.
if (N->hasOneUse() && N->use_begin()->getOpcode() == ISD::TokenFactor)
AddToWorklist(*(N->use_begin()));
Enqueuing these additional TokenFactor-s leads to compile time blow up in some cases:
| before | after | |
|---|---|---|
| time | .7s | 103s |
| # of nodes combined | 8,029 | 1,365,331 |
| # times a TokenFactor was visited | 8,824 | 1,447,721 |
Test case attached. Command line to run:
llc -O2 dagcombine-compile-time-blow-up.ll
Pinging this, as this is an issue that seems to keep coming back with various code patterns.
Another reproducer of compile time blow up: llc -O2 on: https://reviews.llvm.org/P8277
A change that resolved the reproducer I linked is this one: https://reviews.llvm.org/D118877. But it's too big of a hammer and severely affects codegen.