[llvm] e4e22b6 - [SCEV] Use SCEVUnknown(poison) instead of SCEVUnknown(undef).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 01:33:43 PDT 2022


Author: Florian Hahn
Date: 2022-06-27T09:33:05+01:00
New Revision: e4e22b6d80385feb0a8353e1302fa117d3a7240a

URL: https://github.com/llvm/llvm-project/commit/e4e22b6d80385feb0a8353e1302fa117d3a7240a
DIFF: https://github.com/llvm/llvm-project/commit/e4e22b6d80385feb0a8353e1302fa117d3a7240a.diff

LOG: [SCEV] Use SCEVUnknown(poison) instead of SCEVUnknown(undef).

Use poison instead of undef for SCEVUnkown of unreachable values.
This should be in line with the movement to replace undef with poison
when possible.

Suggested in D114650.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D128586

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp
    llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
    llvm/test/Analysis/ScalarEvolution/unreachable-code.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 9a9703f995ee..13afd709cef4 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7196,7 +7196,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(UndefValue::get(V->getType()));
+      return getUnknown(PoisonValue::get(V->getType()));
   } else if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
     return getConstant(CI);
   else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V))

diff  --git a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
index beeacc9d9d6e..bc0f62e827ea 100644
--- a/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
+++ b/llvm/test/Analysis/ScalarEvolution/shift-recurrences.ll
@@ -389,9 +389,9 @@ define void @unreachable_phi() {
 ; CHECK-LABEL: 'unreachable_phi'
 ; CHECK-NEXT:  Classifying expressions for: @unreachable_phi
 ; CHECK-NEXT:    %p_58.addr.1 = phi i32 [ undef, %unreachable1 ], [ %sub2629, %unreachable2 ]
-; CHECK-NEXT:    --> undef U: full-set S: full-set
+; CHECK-NEXT:    --> poison U: full-set S: full-set
 ; CHECK-NEXT:    %sub2629 = sub i32 %p_58.addr.1, 1
-; CHECK-NEXT:    --> undef U: full-set S: full-set
+; CHECK-NEXT:    --> poison U: full-set S: full-set
 ; CHECK-NEXT:  Determining loop execution counts for: @unreachable_phi
 ;
 entry:
@@ -415,7 +415,7 @@ define void @unreachable_binop() {
 ; CHECK-NEXT:    %p_58.addr.1 = phi i32 [ undef, %header ], [ %sub2629, %unreachable ]
 ; CHECK-NEXT:    --> %p_58.addr.1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %header: Variant }
 ; CHECK-NEXT:    %sub2629 = sub i32 %p_58.addr.1, 1
-; CHECK-NEXT:    --> undef U: full-set S: full-set
+; CHECK-NEXT:    --> poison U: full-set S: full-set
 ; CHECK-NEXT:  Determining loop execution counts for: @unreachable_binop
 ; CHECK-NEXT:  Loop %header: Unpredictable backedge-taken count.
 ; CHECK-NEXT:  Loop %header: Unpredictable max backedge-taken count.

diff  --git a/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll b/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll
index 1b856daa78a5..4850f86badfd 100644
--- a/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll
+++ b/llvm/test/Analysis/ScalarEvolution/unreachable-code.ll
@@ -1,7 +1,7 @@
 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
 
 ; CHECK: %t = add i64 %t, 1
-; CHECK: -->  undef
+; CHECK: -->  poison
 
 define void @foo() {
 entry:


        


More information about the llvm-commits mailing list