]> granicus.if.org Git - llvm/commitdiff
[SCEV] Do not bother creating separate SCEVUnknown for unreachable nodes
authorMax Kazantsev <max.kazantsev@azul.com>
Mon, 4 Feb 2019 05:04:19 +0000 (05:04 +0000)
committerMax Kazantsev <max.kazantsev@azul.com>
Mon, 4 Feb 2019 05:04:19 +0000 (05:04 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353017 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/unreachable-code.ll

index c554f9c306f13f5114097409721506a83d2585a4..fcf6a2bfa9f7d04c1a9344321189bca37d2f444d 100644 (file)
@@ -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))
index 51d93981800a22d19f3285d48f7b281cb4350fb5..69a7e39839a7e11f804dc3798c3b1d6e851253ba 100644 (file)
@@ -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: