Skip to content

Commit

Permalink
[SCEV] Do not bother creating separate SCEVUnknown for unreachable nodes
Browse files Browse the repository at this point in the history
Currently, SCEV creates SCEVUnknown for every node of unreachable code. If we
have a huge amounts of such code, we will be littering SE with these nodes. We could
just state that they all are undef and save some memory.

Differential Revision: https://reviews.llvm.org/D57567
Reviewed By: sanjoy

llvm-svn: 353017
  • Loading branch information
Max Kazantsev committed Feb 4, 2019
1 parent b5e945c commit 437ee05
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
@@ -6144,7 +6144,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
// to obey basic rules for definitions dominating uses which this
// analysis depends on.
if (!DT.isReachableFromEntry(I->getParent()))
return getUnknown(V);
return getUnknown(UndefValue::get(V->getType()));
} else if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
return getConstant(CI);
else if (isa<ConstantPointerNull>(V))
2 changes: 1 addition & 1 deletion llvm/test/Analysis/ScalarEvolution/unreachable-code.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s

; CHECK: %t = add i64 %t, 1
; CHECK: --> %t
; CHECK: --> undef

define void @foo() {
entry:

0 comments on commit 437ee05

Please sign in to comment.