[PATCH] D43293: [SimplifyCFG] Don't remove preheaders when we need canonical loops.

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 18 03:12:47 PST 2018


dmgreen added a comment.

> When you remove backedge you introduce new backedge. So you need to add new backedge to the list of the backedges.

I looked into this a little, and had convinced myself that it would be OK (if we add a new backedge, we probably don't want to remove it again in the same pass). Looking at it again though, that might not be correct. I've not done much work in simplify cfg before. Do you think this would involve updating the backedge list in many places?

Perhaps we can turn this around, calculate the Preheaders as `Preds(Headers) - Backedges` and use that instead.

> Maybe we should introduce some annotation to loops that are in simple form.

I don't think that annotations are the way that this is usually handled in llvm, if we can help it. (Plus clang creates preheaders, but wouldn't mark the loops as loop simple form.) I guess the standard way to do this would be to have simplifyCFG know more about loops (using LoopInfo and check if the loop is in simple form). But I suspect that isn't what we would want here if we can take a lighter approach.


https://reviews.llvm.org/D43293





More information about the llvm-commits mailing list