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).
Differential D27469
[LoopVersioning] Require loop-simplify form for loop versioning. fhahn on Dec 6 2016, 10:13 AM. Authored by
Details 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 TimelineComment 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. 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. |