[PATCH] D155255: [SCEV] Don't update the range value if empty
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 17 13:28:25 PDT 2023
davide updated this revision to Diff 541208.
davide edited the summary of this revision.
davide added a comment.
Addressed @nikic and @fhahn review comments
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155255/new/
https://reviews.llvm.org/D155255
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/malloc.ll
llvm/test/Transforms/LoopStrengthReduce/scev-operator-new.ll
Index: llvm/test/Transforms/LoopStrengthReduce/scev-operator-new.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopStrengthReduce/scev-operator-new.ll
@@ -0,0 +1,24 @@
+; RUN: opt < %s -passes=loop-reduce -S | FileCheck %s
+
+; CHECK: define void @patatino() {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label %for.cond9
+
+; CHECK: for.cond9:
+; CHECK-NEXT: br label %for.cond9
+; CHECK-NEXT:}
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @patatino() {
+entry:
+ %call443 = tail call nonnull ptr @_Znam(i64 -1)
+ br label %for.cond9
+
+for.cond9:
+ %lsr.iv = phi ptr [ %call443, %entry ], [ %scevgep, %for.cond9 ]
+ %scevgep = getelementptr i8, ptr %lsr.iv, i64 4
+ br label %for.cond9
+}
+
+declare ptr @_Znam(i64)
Index: llvm/test/Analysis/ScalarEvolution/malloc.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/malloc.ll
+++ llvm/test/Analysis/ScalarEvolution/malloc.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
; RUN: opt -passes='print<scalar-evolution>' -disable-output %s 2>&1 | FileCheck %s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
define ptr @f() {
; CHECK-LABEL: 'f'
; CHECK-NEXT: Classifying expressions for: @f
@@ -23,4 +25,21 @@
ret ptr %alloc
}
+define void @patatino() {
+; CHECK-LABEL: 'patatino'
+; CHECK-NEXT: Classifying expressions for: @patatino
+; CHECK-NEXT: %call443 = tail call nonnull ptr @_Znam(i64 -1)
+; CHECK-NEXT: --> %call443 U: full-set S: full-set
+entry:
+ %call443 = tail call nonnull ptr @_Znam(i64 -1)
+ br label %for.cond9
+
+for.cond9:
+ %lsr.iv = phi ptr [ %call443, %entry ], [ %scevgep, %for.cond9 ]
+ %scevgep = getelementptr i8, ptr %lsr.iv, i64 4
+ br label %for.cond9
+}
+
+declare ptr @_Znam(i64)
+
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
@@ -6833,7 +6833,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: D155255.541208.patch
Type: text/x-patch
Size: 2581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230717/e0ff6aee/attachment.bin>
More information about the llvm-commits
mailing list