This is an archive of the discontinued LLVM Phabricator instance.

[Polly][ScopBuilder] Prefer PHI Write accesses in the statement the incoming value is defined.
ClosedPublic

Authored by Meinersbur on Jan 16 2018, 4:39 PM.

Details

Summary

Theoretically, a PHI write can be added to any statement that represents the incoming basic block. We previously always chose the last because the incoming value's definition is guaranteed to be defined.

With this patch the PHI write is added to the statement that defines the incoming value. It avoids the requirement for a scalar dependency between the defining statement and the statement containing the write. As such the logic for -polly-stmt-granularity=scalar-indep that ensures that there is such scalar dependencies can be removed.

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Jan 16 2018, 4:39 PM

Hi Michael,

this looks generally good. However, did you find an actual use case where this improves the code?

Best,
Tobias

Program                                                                        leone_F30_statementnaming_indep  leone_G30_epilogue_indep diff

 MultiSource/Benchmarks/DOE-ProxyApps-C++/HACCKernels/HACCKernels              0.812                            0.329                     -59.5%
 Performance/Polybench-32/linear-algebra/kernels/symm/Pb32-perf_symm           5.931                            2.813                     -52.6%
 Polybench/Polybench-421/linear-algebra/blas/symm/P421_symm                    1.792                            1.115                     -37.8%
 SingleSource/Benchmarks/Misc/flops                                            6.308                            4.300                     -31.8%
 Performance/Polybench-421/linear-algebra/blas/symm/Pb421-perf_symm            1.545                            1.111                     -28.1%
 Polybench/Polybench-32/linear-algebra/kernels/symm/P32_symm                   6.030                            4.560                     -24.4%
 SingleSource/Benchmarks/Polybench/linear-algebra/kernels/symm/symm           12.032                            9.293                     -22.8%
 SingleSource/Benchmarks/Polybench/stencils/fdtd-apml/fdtd-apml                0.464                            0.540                      16.4%
 MultiSource/Benchmarks/TSVC/Symbolics-flt/Symbolics-flt                       0.867                            0.785                      -9.5%
 MultiSource/Benchmarks/TSVC/Symbolics-dbl/Symbolics-dbl                       2.209                            2.392                       8.3%
 SingleSource/Benchmarks/CoyoteBench/almabench                                 9.829                            9.170                      -6.7%
 Polybench/Polybench-421/linear-algebra/blas/symm/P421r_symm                   1.659                            1.559                      -6.0%

I am somewhat suprised by this positive result. I made the patch primarily because it simplifies the equivalence class code and estimated that too many coincidences had to occur before it had an effect on the rescheduler. Since improvement it consistent, I assume it is not just caused by different statement names.

grosser accepted this revision.Jan 19 2018, 5:27 AM

Nice!

This revision is now accepted and ready to land.Jan 19 2018, 5:27 AM
This revision was automatically updated to reflect the committed changes.