[PATCH] D28812: [SCEV] Introduce add operation inlining limit
Daniil Fukalov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 26 05:44:35 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293176: [SCEV] Introduce add operation inlining limit (authored by dfukalov).
Changed prior to commit:
https://reviews.llvm.org/D28812?vs=84683&id=85892#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28812
Files:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/test/Analysis/ScalarEvolution/max-addops-inline.ll
Index: llvm/trunk/test/Analysis/ScalarEvolution/max-addops-inline.ll
===================================================================
--- llvm/trunk/test/Analysis/ScalarEvolution/max-addops-inline.ll
+++ llvm/trunk/test/Analysis/ScalarEvolution/max-addops-inline.ll
@@ -0,0 +1,17 @@
+; RUN: opt -analyze -scalar-evolution -scev-addops-inline-threshold=1 < %s | FileCheck --check-prefix=CHECK1 %s
+; RUN: opt -analyze -scalar-evolution -scev-addops-inline-threshold=10 < %s | FileCheck --check-prefix=CHECK10 %s
+
+define i32 @foo(i64 %p0, i32 %p1) {
+; CHECK1: %add2 = add nsw i32 %mul1, %add
+; CHECK1-NEXT: --> ((trunc i64 %p0 to i32) * (1 + (trunc i64 %p0 to i32)) * (1 + %p1))
+
+; CHECK10: %add2 = add nsw i32 %mul1, %add
+; CHECK10-NEXT: --> ((trunc i64 %p0 to i32) * (1 + ((trunc i64 %p0 to i32) * (1 + %p1)) + %p1))
+entry:
+ %tr = trunc i64 %p0 to i32
+ %mul = mul nsw i32 %tr, %p1
+ %add = add nsw i32 %mul, %tr
+ %mul1 = mul nsw i32 %add, %tr
+ %add2 = add nsw i32 %mul1, %add
+ ret i32 %add2
+}
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -127,6 +127,11 @@
cl::desc("Threshold for inlining multiplication operands into a SCEV"),
cl::init(1000));
+static cl::opt<unsigned> AddOpsInlineThreshold(
+ "scev-addops-inline-threshold", cl::Hidden,
+ cl::desc("Threshold for inlining multiplication operands into a SCEV"),
+ cl::init(500));
+
static cl::opt<unsigned>
MaxCompareDepth("scalar-evolution-max-compare-depth", cl::Hidden,
cl::desc("Maximum depth of recursive compare complexity"),
@@ -2219,6 +2224,9 @@
if (Idx < Ops.size()) {
bool DeletedAdd = false;
while (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(Ops[Idx])) {
+ if (Ops.size() > AddOpsInlineThreshold ||
+ Add->getNumOperands() > AddOpsInlineThreshold)
+ break;
// If we have an add, expand the add operands onto the end of the operands
// list.
Ops.erase(Ops.begin()+Idx);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28812.85892.patch
Type: text/x-patch
Size: 2137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170126/f7b48881/attachment.bin>
More information about the llvm-commits
mailing list