[PATCH] D87160: [SCEV] Recognize min/max intrinsics
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 5 07:31:53 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac87480bd8be: [SCEV] Recognize min/max intrinsics (authored by nikic).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87160/new/
https://reviews.llvm.org/D87160
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/minmax-intrinsics.ll
Index: llvm/test/Analysis/ScalarEvolution/minmax-intrinsics.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/minmax-intrinsics.ll
+++ llvm/test/Analysis/ScalarEvolution/minmax-intrinsics.ll
@@ -11,7 +11,7 @@
; CHECK-LABEL: 'umax'
; CHECK-NEXT: Classifying expressions for: @umax
; CHECK-NEXT: %z = call i32 @llvm.umax.i32(i32 %x, i32 %y)
-; CHECK-NEXT: --> %z U: full-set S: full-set
+; CHECK-NEXT: --> (%x umax %y) U: full-set S: full-set
; CHECK-NEXT: Determining loop execution counts for: @umax
;
%z = call i32 @llvm.umax.i32(i32 %x, i32 %y)
@@ -22,7 +22,7 @@
; CHECK-LABEL: 'umin'
; CHECK-NEXT: Classifying expressions for: @umin
; CHECK-NEXT: %z = call i32 @llvm.umin.i32(i32 %x, i32 %y)
-; CHECK-NEXT: --> %z U: full-set S: full-set
+; CHECK-NEXT: --> (%x umin %y) U: full-set S: full-set
; CHECK-NEXT: Determining loop execution counts for: @umin
;
%z = call i32 @llvm.umin.i32(i32 %x, i32 %y)
@@ -33,7 +33,7 @@
; CHECK-LABEL: 'smax'
; CHECK-NEXT: Classifying expressions for: @smax
; CHECK-NEXT: %z = call i32 @llvm.smax.i32(i32 %x, i32 %y)
-; CHECK-NEXT: --> %z U: full-set S: full-set
+; CHECK-NEXT: --> (%x smax %y) U: full-set S: full-set
; CHECK-NEXT: Determining loop execution counts for: @smax
;
%z = call i32 @llvm.smax.i32(i32 %x, i32 %y)
@@ -44,7 +44,7 @@
; CHECK-LABEL: 'smin'
; CHECK-NEXT: Classifying expressions for: @smin
; CHECK-NEXT: %z = call i32 @llvm.smin.i32(i32 %x, i32 %y)
-; CHECK-NEXT: --> %z U: full-set S: full-set
+; CHECK-NEXT: --> (%x smin %y) U: full-set S: full-set
; CHECK-NEXT: Determining loop execution counts for: @smin
;
%z = call i32 @llvm.smin.i32(i32 %x, i32 %y)
@@ -55,9 +55,9 @@
; CHECK-LABEL: 'clamp'
; CHECK-NEXT: Classifying expressions for: @clamp
; CHECK-NEXT: %y = call i32 @llvm.umax.i32(i32 %x, i32 10)
-; CHECK-NEXT: --> %y U: full-set S: full-set
+; CHECK-NEXT: --> (10 umax %x) U: [10,0) S: [10,0)
; CHECK-NEXT: %z = call i32 @llvm.umin.i32(i32 %y, i32 20)
-; CHECK-NEXT: --> %z U: full-set S: full-set
+; CHECK-NEXT: --> (20 umin (10 umax %x)) U: [10,21) S: [10,21)
; CHECK-NEXT: Determining loop execution counts for: @clamp
;
%y = call i32 @llvm.umax.i32(i32 %x, i32 10)
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -6341,6 +6341,25 @@
case Instruction::Invoke:
if (Value *RV = cast<CallBase>(U)->getReturnedArgOperand())
return getSCEV(RV);
+
+ if (auto *II = dyn_cast<IntrinsicInst>(U)) {
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::umax:
+ return getUMaxExpr(getSCEV(II->getArgOperand(0)),
+ getSCEV(II->getArgOperand(1)));
+ case Intrinsic::umin:
+ return getUMinExpr(getSCEV(II->getArgOperand(0)),
+ getSCEV(II->getArgOperand(1)));
+ case Intrinsic::smax:
+ return getSMaxExpr(getSCEV(II->getArgOperand(0)),
+ getSCEV(II->getArgOperand(1)));
+ case Intrinsic::smin:
+ return getSMinExpr(getSCEV(II->getArgOperand(0)),
+ getSCEV(II->getArgOperand(1)));
+ default:
+ break;
+ }
+ }
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87160.290087.patch
Type: text/x-patch
Size: 3395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200905/7ad0e68f/attachment.bin>
More information about the llvm-commits
mailing list