Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix performance problem in LLVM JumpThreading
This patch is https://reviews.llvm.org/D42262 upstream. When we emit unboxed unions, we tend to emit `switch` instructions on a small integer which serves as a marker for which of types is currently active, so we often emit things like: ``` block: ; Incoming from a union split branch %phi = i8 phi [1, %a], [2, %b] < Some other operation not on the union split> ; Union split again switch i8 %phi, label %boxed [ i8 1, %abranch i8 2, %bbranch ] ``` In many situations the operation in the middle can get optimized away, so we want to merge the two union split sections into one. LLVM's jump threading pass can do this by keeping track of how control flow behaves across a given basic block. Unfortunately, this optimization wasn't taking effect. This is because InstCombine realized that the range of possible values was rather small and turned the above into something like: ``` %trunc = truc i8 %phi to i2 switch i2 %trunc, label %boxed [ i2 1, %abranch i2 -2, %bbranch ] ``` which JumpThreading refused to look through (because of the i2 rather than the i1). The included patch fixes this. On recent LLVM, we additionally need https://reviews.llvm.org/D42260, for cases where a union split branch happens to target a loop header. However, LLVM 3.9.1 does not include the original commit that regressed that. This fixes a number of the performance regressions seen in JuliaLang#25261.
- Loading branch information