[PATCH] D41812: [CVP] Replace incoming values from unreachable blocks with undef

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 07:10:41 PST 2018


anna accepted this revision.
anna added a comment.
This revision is now accepted and ready to land.

LGTM w/ comments.



================
Comment at: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:134
+    BasicBlock *IncomingBB = P->getIncomingBlock(i);
+    if (!ReachableBlocks.count(IncomingBB)) {
+      P->setIncomingValue(i, UndefValue::get(P->getType()));
----------------
The reasons for this code here is 2 fold right:
1. avoid querying LVI for unreachable block BB
2. transforming the incoming value so that transformation further below don't mess around with such IR in unreachable blocks.

It's really #2 that fixes this issue. #1 just avoids unnecessary work. 

I agree that this change by itself is a good one to have (it also has the side effect of avoiding IR pattern in *this single* instance of SimplifyInstruction).


================
Comment at: test/Transforms/CorrelatedValuePropagation/pr35807.ll:41
+
+bb12:
+  br label %bb14
----------------
All of these are unreachable blocks, could you pls rename them or perhaps add a comment on bb14 stating its unreachable block.


https://reviews.llvm.org/D41812





More information about the llvm-commits mailing list