This patch helps JumpThreading capture more optimization opportunities. No significant performance change in SpecINT.
Diff Detail
- Repository
- rL LLVM
Event Timeline
It is not clear to me from looking at the added test case what new optimization is being added. I would expect to see some CHECKs of new folded constants if I understand the change correctly.
| test/Transforms/JumpThreading/basic.ll | ||
|---|---|---|
| 495 | These 3 lines are indented funny (tabs?) | |
This patch allows the Entry block threads over the merge block. See the first CHECK-NEXT
| test/Transforms/JumpThreading/basic.ll | ||
|---|---|---|
| 493 | It seems like this change to JumpThreading would not be needed if the Merge block code had been simplified to the following: Merge: %B = phi i32 [1, %Entry], [%v1, %F1] %M = icmp eq i32 %B, 0 br i1 %M, label %T2, label %F2 Are we missing this simplification, or is there something more complex going on in the code this was extracted from that prevents it from happening? | |
| test/Transforms/JumpThreading/basic.ll | ||
|---|---|---|
| 493 | The simplification is missing. InstCombine can optimize it, but it is called after jumpthreading. | |
| test/Transforms/JumpThreading/basic.ll | ||
|---|---|---|
| 493 | InstSimplify can also optimize it. Have you considered just using the simplified value if the instruction can be simplified? This frequently happens due to phi translation and I think there is an instance where we use this in DuplicateCondBranchOnPHIIntoPred | |
| lib/Transforms/Scalar/JumpThreading.cpp | ||
|---|---|---|
| 413 | Please use auto * for the left hand side of the assignment. | |
LGTM once you've addressed the comments.
| lib/Transforms/Scalar/JumpThreading.cpp | ||
|---|---|---|
| 415 | You might need to RAUW NewV, | |
| lib/Transforms/Scalar/JumpThreading.cpp | ||
|---|---|---|
| 415 | I meant V->replaceAllUsesWith(NewV) | |
Seems reasonable to me, but I'll let @bmakam's or someone else more familiar with the patch give the final approval.
Please use auto * for the left hand side of the assignment.