[PATCH] D30446: [IndVars] Do not branch on poison

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 16 10:54:49 PDT 2017


sanjoy added a comment.

In https://reviews.llvm.org/D30446#702912, @atrick wrote:

> Ok. I thought the problem was caused by converting the loop test to a post-increment compare. Is that a problem?


Yes, but that isn't the only problem.

> The problem you've been talking about is caused by FindLoopCounter.

Yes.

> This is mostly about setting up a specific pattern of loop for count-down-to-zero codegen. I wanted to make sure we don't create additional IVs in the process. A side effect is that we can reduce the number of IVs for some loops as a "nice" simplification. That doesn't seem worth doing if we need to erase flags. Why doesn't FindLoopCounter just check isIVNeverPoison?

That would be correct, but it pessimizes the case where it would have been okay, for the various reasons outlined in the code for this patch, to nevertheless emit a branch on a potentially poison IV.

> At any rate, FindLoopCounter is making the wrong choice here. I don't understand why it's picking an "AlmostDead" IV over an IV that starts at non-zero.

Are you talking about the example I pasted above?  Then the IV picked by `FindLoopCounter` is not AlmostDead, since it (deliberately) has a use in the `never_taken` block.


https://reviews.llvm.org/D30446





More information about the llvm-commits mailing list