Skip to content

Commit 6c8f4c1

Browse files
staticfloatgiordano
authored andcommitted
Disable pathologically expensive SimplifySelectOps optimization
`SimplifySelectOps` is a late optimization in LLVM that attempts to translate `select(C, load(A), load(B))` into `load(select(C, A, B))`. However, in order for it to do this optimization, it needs to check that `C` does not depend on the result of `load(A)` or `load(B)`. Unfortunately (unlikely Julia and LLVM at the IR level), LLVM does not have a topological order of statements computed at this stage of the compiler, so LLVM needs to iterate through all statements in the function in order to perform this legality check. For large functions, this is extremely expensive, accounting for the majority of all compilation time for such functions. On the other hand, the optimization itself is minor, allowing at most the elision of one additional load (and doesn't fire particularly often, because the middle end can perform similar optimizations). Until there is a proper solution in LLVM, simply disable this optimizations, making LLVM several orders of magnitude faster on real world benchmarks. X-ref: llvm#60132 (cherry picked from commit 8a2c8f5) (cherry picked from commit d7563d0)
1 parent c7d705b commit 6c8f4c1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27292,6 +27292,7 @@ bool DAGCombiner::SimplifySelectOps(SDNode *TheSelect, SDValue LHS,
2729227292
!TLI.isOperationLegalOrCustom(TheSelect->getOpcode(),
2729327293
LLD->getBasePtr().getValueType()))
2729427294
return false;
27295+
return false;
2729527296

2729627297
// The loads must not depend on one another.
2729727298
if (LLD->isPredecessorOf(RLD) || RLD->isPredecessorOf(LLD))

0 commit comments

Comments
 (0)