This is an archive of the discontinued LLVM Phabricator instance.

[GVN] Preserve loop related analysis/canonical forms.
ClosedPublic

Authored by fhahn on Jul 23 2019, 3:15 AM.

Details

Summary

LoopInfo can be easily preserved by passing it to the functions that
modify the CFG (SplitCriticalEdge and MergeBlockIntoPredecessor.
SplitCriticalEdge also preserves LoopSimplify and LCSSA form when when passing in
LoopInfo. The test case shows that we preserve LoopSimplify and
LoopInfo. Adding addPreservedID(LCSSAID) did not preserve LCSSA for some
reason.

Also I am not sure if it is possible to preserve those in the new pass
manager, as they aren't analysis passes.

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Jul 23 2019, 3:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2019, 3:15 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

Minor comments.

llvm/lib/Transforms/Scalar/GVN.cpp
2478 ↗(On Diff #211270)

These changes, incl. the isCriticalEdge modifications above, seem unrelated to the loop info issue, are they?

llvm/test/Transforms/GVN/preserve-analysis.ll
50 ↗(On Diff #211270)

You should check that GVN did something as well.

fhahn updated this revision to Diff 211279.Jul 23 2019, 5:25 AM
fhahn marked 2 inline comments as done.

Address Johannes' comments

fhahn added inline comments.Jul 23 2019, 5:30 AM
llvm/lib/Transforms/Scalar/GVN.cpp
2478 ↗(On Diff #211270)

They do, but I should have made that clear. SplitCiriticalEdge will insert additional blocks to preserve LoopSimplify form, if LI is passed. Such a block might be inserted between B and one of its predecessors, which would cause GetNumSuccessor to assert. It is safer to just do it in 2 steps.

jdoerfert accepted this revision.Jul 23 2019, 5:52 AM

LGTM.

Thanks for the code comment, that will help the next person as well :)

This revision is now accepted and ready to land.Jul 23 2019, 5:52 AM
fhahn added a comment.Jul 23 2019, 1:48 PM

Thanks!

Compile time numbers on X86 with -O3 look promising as well

Metric: compile_time

Program master patch diff
test-suite...000/183.equake/183.equake.test 0.39 0.39 -0.9%
test-suite...:: CTMark/sqlite3/sqlite3.test 11.07 11.01 -0.5%
test-suite...T2000/300.twolf/300.twolf.test 5.68 5.66 -0.4%
test-suite...SPEC/CINT95/099.go/099.go.test 3.84 3.82 -0.4%
test-suite...C/CFP2000/179.art/179.art.test 0.39 0.39 -0.4%
test-suite...129.compress/129.compress.test 0.18 0.18 -0.3%
test-suite...000/197.parser/197.parser.test 2.39 2.38 -0.3%
test-suite...6/464.h264ref/464.h264ref.test 14.67 14.63 -0.3%
test-suite :: CTMark/SPASS/SPASS.test 11.88 11.85 -0.3%
test-suite...nal/skidmarks10/skidmarks.test 1.86 1.85 -0.2%
test-suite.../CINT2000/175.vpr/175.vpr.test 2.76 2.76 -0.2%
test-suite...T2006/456.hmmer/456.hmmer.test 6.45 6.43 -0.2%
test-suite...TMark/7zip/7zip-benchmark.test 39.82 39.73 -0.2%
test-suite...CFP2000/188.ammp/188.ammp.test 2.65 2.64 -0.2%
test-suite.../CINT2000/252.eon/252.eon.test 55.19 55.31 0.2%
test-suite...T2006/458.sjeng/458.sjeng.test 2.11 2.10 -0.2%
test-suite :: CTMark/Bullet/bullet.test 25.51 25.46 -0.2%
test-suite...006/447.dealII/447.dealII.test 117.87 117.67 -0.2%
test-suite...Mark/mafft/pairlocalalign.test 8.77 8.76 -0.2%
test-suite...6/482.sphinx3/482.sphinx3.test 3.90 3.89 -0.2%
test-suite.../CINT2000/176.gcc/176.gcc.test 23.03 22.99 -0.2%
test-suite.../CINT2000/254.gap/254.gap.test 9.72 9.70 -0.2%
test-suite.../CINT95/134.perl/134.perl.test 4.83 4.83 -0.2%
test-suite...T2006/401.bzip2/401.bzip2.test 1.85 1.85 -0.2%
test-suite...CFP2000/177.mesa/177.mesa.test 9.97 9.95 -0.2%
test-suite.../CINT2000/181.mcf/181.mcf.test 0.52 0.52 -0.2%
test-suite...INT95/132.ijpeg/132.ijpeg.test 4.69 4.69 -0.1%
test-suite...006/453.povray/453.povray.test 27.30 27.27 -0.1%
test-suite...0/253.perlbmk/253.perlbmk.test 9.86 9.85 -0.1%
test-suite...:: External/Povray/povray.test 12.34 12.32 -0.1%
test-suite...SPEC/CINT95/130.li/130.li.test 1.57 1.57 -0.1%
test-suite...CFP2006/433.milc/433.milc.test 3.19 3.18 -0.1%
test-suite...INT2000/164.gzip/164.gzip.test 1.21 1.20 -0.1%
test-suite...-typeset/consumer-typeset.test 9.50 9.48 -0.1%
test-suite...ternal/HMMER/hmmcalibrate.test 6.42 6.42 -0.1%
test-suite...T2006/445.gobmk/445.gobmk.test 14.04 14.03 -0.1%
test-suite...T95/147.vortex/147.vortex.test 6.79 6.78 -0.1%
test-suite...5/124.m88ksim/124.m88ksim.test 4.03 4.02 -0.1%
test-suite :: External/Nurbs/nurbs.test 2.14 2.13 -0.1%
test-suite...ark/tramp3d-v4/tramp3d-v4.test 20.79 20.77 -0.1%
test-suite :: CTMark/lencod/lencod.test 15.30 15.29 -0.1%
test-suite...3.xalancbmk/483.xalancbmk.test 181.02 180.88 -0.1%
test-suite...006/450.soplex/450.soplex.test 29.88 29.90 0.1%
test-suite...:: CTMark/ClamAV/clamscan.test 14.01 14.00 -0.1%
test-suite...000/186.crafty/186.crafty.test 3.20 3.20 -0.1%
test-suite...T2006/473.astar/473.astar.test 1.36 1.36 -0.1%
test-suite.../CINT2006/429.mcf/429.mcf.test 0.52 0.52 -0.1%
test-suite...T2000/256.bzip2/256.bzip2.test 0.72 0.72 -0.1%
test-suite...C/CFP2006/470.lbm/470.lbm.test 0.22 0.22 -0.0%
test-suite...6/471.omnetpp/471.omnetpp.test 36.50 36.51 0.0%
test-suite...CFP2006/444.namd/444.namd.test 6.37 6.37 -0.0%
test-suite...000/255.vortex/255.vortex.test 6.79 6.79 -0.0%
test-suite...libquantum/462.libquantum.test 0.86 0.86 -0.0%
test-suite...0.perlbench/400.perlbench.test 19.05 19.05 0.0%
test-suite.../CINT2006/403.gcc/403.gcc.test 51.13 51.12 -0.0%
test-suite :: CTMark/kimwitu++/kc.test 14.78 14.79 0.0%
Geomean difference -0.2%

This revision was automatically updated to reflect the committed changes.