[PATCH] D159160: [SCEV] Fix potentially empty set for unsigned ranges

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 02:48:38 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0609b65aaf03: [SCEV] Fix potentially empty set for unsigned ranges (authored by tejas, committed by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D159160?vs=555648&id=555693#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159160/new/

https://reviews.llvm.org/D159160

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/malloc.ll


Index: llvm/test/Analysis/ScalarEvolution/malloc.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/malloc.ll
+++ llvm/test/Analysis/ScalarEvolution/malloc.ll
@@ -23,4 +23,15 @@
   ret ptr %alloc
 }
 
+define ptr @undefined_max() {
+; CHECK-LABEL: 'undefined_max'
+; CHECK-NEXT:  Classifying expressions for: @undefined_max
+; CHECK-NEXT:    %alloc = call nonnull ptr @malloc(i64 -1)
+; CHECK-NEXT:    -->  %alloc U: full-set S: full-set
+; CHECK-NEXT:  Determining loop execution counts for: @undefined_max
+;
+  %alloc = call nonnull ptr @malloc(i64 -1)
+  ret ptr %alloc
+}
+
 declare noalias noundef ptr @malloc(i64 noundef) allockind("alloc,uninitialized") allocsize(0)
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6843,7 +6843,7 @@
         if (llvm::isKnownNonZero(V, DL))
           MinVal = Align;
         ConservativeResult = ConservativeResult.intersectWith(
-            {MinVal, MaxVal + 1}, RangeType);
+            ConstantRange::getNonEmpty(MinVal, MaxVal + 1), RangeType);
       }
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159160.555693.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230904/3fd85690/attachment.bin>


More information about the llvm-commits mailing list