[PATCH] D57567: [SCEV] Do not bother creating separate SCEVUnknown for unreachable nodes

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 23:23:03 PST 2019


mkazantsev created this revision.
mkazantsev added reviewers: sanjoy, skatkov.
Herald added a subscriber: javed.absar.

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 zero and save some memory.


https://reviews.llvm.org/D57567

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


Index: test/Analysis/ScalarEvolution/unreachable-code.ll
===================================================================
--- test/Analysis/ScalarEvolution/unreachable-code.ll
+++ test/Analysis/ScalarEvolution/unreachable-code.ll
@@ -1,7 +1,7 @@
 ; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
 
 ; CHECK: %t = add i64 %t, 1
-; CHECK: -->  %t
+; CHECK: -->  0
 
 define void @foo() {
 entry:
Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -6144,7 +6144,7 @@
     // to obey basic rules for definitions dominating uses which this
     // analysis depends on.
     if (!DT.isReachableFromEntry(I->getParent()))
-      return getUnknown(V);
+      return getZero(V->getType());
   } else if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
     return getConstant(CI);
   else if (isa<ConstantPointerNull>(V))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57567.184685.patch
Type: text/x-patch
Size: 955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190201/7e80501e/attachment.bin>


More information about the llvm-commits mailing list