[PATCH] D37460: [GVN] Prevent LoadPRE from hoisting through guards

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 01:36:23 PDT 2017


dberlin added a comment.

In https://reviews.llvm.org/D37460#864436, @mkazantsev wrote:

> Actually we don't even need OrderedInstructions to do that. It's enough to maintain a set of blocks where we have ever seen the guards. We iterate through blocks in reverse postorder which guarantees us that if a block has one predecessor it will be visited before the block. We also traverse block instructions in direct order. Using this, we just mark a block as having a guard when we meet one and know for sure that:
>
> 1. if the current block is marked, there is a guard above the current instruction, and we cannot hoist;
> 2. if the only predecessor (recursively) is marked, it also blocks us from hoisting.
>
>   I've updated the patch using this solution. Please let me know if it makes sense to you.


Sure, this will work, but it requires clearing the guard set between iterations :)
Given how much faster either solution is than the original option, seems fine to me. I doubt it will ever be a real performance issue.


https://reviews.llvm.org/D37460





More information about the llvm-commits mailing list