[PATCH] D34150: [LV] Test once if vector trip count is zero, instead of twice

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 09:49:38 PDT 2017


wmi added a comment.

In https://reviews.llvm.org/D34150#802750, @mkuper wrote:

> Re overflow - the point is that  getOrCreateTripCount() returns, basically, PSE.getBackedgeTakenCount() + 1, and that may overflow, so the "trip count" may end up being 0 if the backedge taken count is 0. I don't think this is outdated, and this is behavior we want to preserve. But this patch should preserve this behavior IIUC. Can you make sure there's a test for this?


max_i32_backedgetaken in test/Transforms/LoopVectorize/induction.ll is the orginal test for overflow case. The patch generates correct code for it.

> Anyway, the logic seems sound, but I'd like wmi to look at it - he added the minimum iterations check in r245952, and combined it with the overflow check, instead of the VTC==0 check.
>  Wei, is there some case we're missing here?

The logic looks good to me. It is a nice improvement.

> One more thing about the description: "In this case a single (the last) vector iteration is peeled and replaced with VF*UF scalar iterations (instead of none), reducing VTC by 1." <-- this is confusing. That only happens if STC == 0 (mod VF * UF). So the logic is correct, since this is indeed what happens when STC == VF * UF, but I would phrase it differently.




https://reviews.llvm.org/D34150





More information about the llvm-commits mailing list