Eliminate unnecessary unsafeEqualityProof
This patch addresses #20143, which wants to discard unused calls to unsafeEqualityProof. There are two parts: * In exprOkForSideEffects, we want to know that unsafeEqualityProof indeed terminates, without any exceptions etc * But we can only discard the case if we know that the coercion variable is not used, which means we have to gather accurate occurrence info for CoVars. Previously OccurAnal only did a half hearted job of doing so; this patch finishes the job. See Note [Gather occurrences of coercion variables] in OccurAnal. Because the occurrence analyser does more work, there is a small compile-time cost but it's pretty small. The compiler perf tests are usually 0.0% but occasionally up to 0.3% increase. I'm just going to accept this -- gathering accurate occurrence information really seems like the Right Thing to do. There is an increase in `compile_time/peak_megabytes_allocated`, for T11545, or around 14%; but I can't reproduce it on my machine (it's the same before and after), and the peak-usage stats are vulnerable to when exactly the GC takes place, so I'm just going to accept it. Metric Increase: T11545
Showing
- compiler/GHC/Core/Opt/OccurAnal.hs 68 additions, 44 deletionscompiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Utils.hs 34 additions, 6 deletionscompiler/GHC/Core/Utils.hs
- testsuite/tests/simplCore/should_compile/T20143.hs 20 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T20143.hs
- testsuite/tests/simplCore/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/simplCore/should_compile/all.T
Loading
Please register or sign in to comment