Requiring loop-simplify form for loop versioning ensures that the
runtime check block always dominates the exit block.
This patch closes #30958 (https://llvm.org/bugs/show_bug.cgi?id=30958).
Paths
| Differential D27469
[LoopVersioning] Require loop-simplify form for loop versioning. ClosedPublic Authored by fhahn on Dec 6 2016, 10:13 AM.
Details Summary Requiring loop-simplify form for loop versioning ensures that the This patch closes #30958 (https://llvm.org/bugs/show_bug.cgi?id=30958).
Diff Detail Event TimelineThis revision is now accepted and ready to land.Dec 6 2016, 11:08 AM Comment Actions @efriedma Only versioning loops that are in loop simplify form would prevent the error case. If that's the preferred solution I'd be happy to update the patch. Comment Actions Making versionLoop() assert that the loop is in loop-simplify form is probably a good idea; versionLoop() is already assuming the loop has a preheader, so it's not much of a stretch. Granted, I'm not sure how much code needs to be fixed to correctly preserve loop-simplify form; versionLoop() itself doesn't preserve it correctly. Comment Actions
I agree with Eli; we generally avoid this kind of situation by only handling loops that can be in loop-simplify form. Comment Actions
Yeah, same here, thank Eli! I even tried -loop-simplify on the test case before first replying but I failed to notice that it created an exit block that *no longer* dominated the loop header. So I wrongly concluded that loop-simplify wouldn't help here. fhahn retitled this revision from [LoopVersioning] Check if exit block dominates runtime check block. to [LoopVersioning] Require loop-simplify form for loop versioning.. fhahn updated this object. fhahn edited edge metadata. Comment ActionsRequire loop-simplify form for loop versioning, as per review comments. Comment Actions This patch changed substantially since @anemet accepted it and it would be great if somebody could have another look. The patch now requires loop-simplify form for loop versioning and the other optimizations requiring loop versioning, which may be to strict. Comment Actions It’s good to avoid loop which are not in loop-simplify form. This looks OK to me except a minor comment.
Comment Actions @ashutosh.nema thanks for pointing that out, I've moved the check to legalLoopStructure and removed the redundant checks.
Revision Contents
Diff 81941 lib/Transforms/Scalar/LoopDistribute.cpp
lib/Transforms/Scalar/LoopLoadElimination.cpp
lib/Transforms/Scalar/LoopVersioningLICM.cpp
lib/Transforms/Utils/LoopVersioning.cpp
test/Transforms/LoopDistribute/diagnostics-with-hotness.ll
test/Transforms/LoopDistribute/diagnostics.ll
test/Transforms/LoopVectorize/diag-with-hotness-info.ll
test/Transforms/LoopVersioning/exit-block-dominates-rt-check-block.ll
test/Transforms/LoopVersioning/noalias-version-twice.ll
|
Please move this check to "legalLoopStructure".