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

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 01:21:28 PDT 2017


mkazantsev updated this revision to Diff 114311.
mkazantsev added a comment.

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.


https://reviews.llvm.org/D37460

Files:
  include/llvm/Transforms/Scalar/GVN.h
  lib/Transforms/Scalar/GVN.cpp
  test/Transforms/GVN/PRE/pre-load-guards.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37460.114311.patch
Type: text/x-patch
Size: 6755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170908/30d300c5/attachment.bin>


More information about the llvm-commits mailing list