Skip to content

Commit c1b3e32

Browse files
committed
[NFC][InstructionSimplify] Add a warning about not simplifying to not def-reachable
See https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20200824/824235.html and https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20200824/824967.html InstSimply is not allowed to perform simplifications to instructions that are not def-reachable from the original instruction.
1 parent 08669fb commit c1b3e32

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

llvm/include/llvm/Analysis/InstructionSimplify.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
// same call context of that function (and not split between caller and callee
2727
// contexts of a directly recursive call, for example).
2828
//
29+
// Additionally, these routines can't simplify to the instructions that are not
30+
// def-reachable, meaning we can't just scan the basic block for instructions
31+
// to simplify to.
32+
//
2933
//===----------------------------------------------------------------------===//
3034

3135
#ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4403,6 +4403,10 @@ Value *llvm::SimplifyExtractElementInst(Value *Vec, Value *Idx,
44034403

44044404
/// See if we can fold the given phi. If not, returns null.
44054405
static Value *SimplifyPHINode(PHINode *PN, const SimplifyQuery &Q) {
4406+
// WARNING: no matter how worthwhile it may seem, we can not perform PHI CSE
4407+
// here, because the PHI we may succeed simplifying to was not
4408+
// def-reachable from the original PHI!
4409+
44064410
// If all of the PHI's incoming values are the same then replace the PHI node
44074411
// with the common value.
44084412
Value *CommonValue = nullptr;

0 commit comments

Comments
 (0)