[SCEV] Fix ScalarEvolution tests under NPM
Many tests use opt's -analyze feature, which does not translate well to
NPM and has better alternatives. The alternative here is to explicitly
add a pass that calls ScalarEvolution::print().
The legacy pass manager RUNs aren't changing, but they are now pinned to
the legacy pass manager. For each legacy pass manager RUN, I added a
corresponding NPM RUN using the 'print<scalar-evolution>' pass. For
compatibility with update_analyze_test_checks.py and existing test
CHECKs, 'print<scalar-evolution>' now prints what -analyze prints per
function.
This was generated by the following Python script and failures were
manually fixed up:
import sys
for i in sys.argv:
with open(i, 'r') as f:
s = f.read()
with open(i, 'w') as f:
for l in s.splitlines():
if "RUN:" in l and ' -analyze ' in l and '\\' not in l:
f.write(l.replace(' -analyze ', ' -analyze -enable-new-pm=0 '))
f.write('\n')
f.write(l.replace(' -analyze ', ' -disable-output ').replace(' -scalar-evolution ', ' "-passes=print<scalar-evolution>" ').replace(" | ", " 2>&1 | "))
f.write('\n')
else:
f.write(l)
There are a couple failures still in ScalarEvolution under NPM, but
those are due to other unrelated naming conflicts.
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D83798
2020-07-17 02:09:47 +08:00
|
|
|
; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
|
|
|
|
; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
|
[SCEV] Limit AddRec "simplifications" to avoid combinatorial explosions
SCEV's transform that turns `{A1,+,A2,+,...,+,An}<L> * {B1,+,B2,+,...,+,Bn}<L>` into
a single AddRec of size `2n+1` with complex combinatorial coefficients can easily
trigger exponential growth of the SCEV (in case if nothing gets folded and simplified).
We tried to restrain this transform using the option `scalar-evolution-max-add-rec-size`,
but its default value seems to be insufficiently small: the test attached to this patch
with default value of this option `16` has a SCEV of >3M symbols (when printed out).
This patch reduces the simplification limit. It is not a cure to combinatorial
explosions, but at least it reduces this corner case to something more or less
reasonable.
Differential Revision: https://reviews.llvm.org/D53282
Reviewed By: sanjoy
llvm-svn: 344584
2018-10-16 13:26:21 +08:00
|
|
|
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
|
|
|
|
|
|
|
|
; Check that we don't have unreasonably huge SCEVs and in particular only a
|
|
|
|
; reasonable amount of AddRecs in the notation of %tmp19. If we "simplify" SCEVs
|
|
|
|
; too aggressively, we may end up with huge nested expressions.
|
|
|
|
define void @test(i32 %x, i64 %y, i1 %cond) {
|
|
|
|
|
|
|
|
; CHECK: %tmp19 = mul i32 %tmp17, %tmp18
|
2018-11-01 14:18:27 +08:00
|
|
|
; CHECK: ((((((
|
[SCEV] Limit AddRec "simplifications" to avoid combinatorial explosions
SCEV's transform that turns `{A1,+,A2,+,...,+,An}<L> * {B1,+,B2,+,...,+,Bn}<L>` into
a single AddRec of size `2n+1` with complex combinatorial coefficients can easily
trigger exponential growth of the SCEV (in case if nothing gets folded and simplified).
We tried to restrain this transform using the option `scalar-evolution-max-add-rec-size`,
but its default value seems to be insufficiently small: the test attached to this patch
with default value of this option `16` has a SCEV of >3M symbols (when printed out).
This patch reduces the simplification limit. It is not a cure to combinatorial
explosions, but at least it reduces this corner case to something more or less
reasonable.
Differential Revision: https://reviews.llvm.org/D53282
Reviewed By: sanjoy
llvm-svn: 344584
2018-10-16 13:26:21 +08:00
|
|
|
; CHECK-NOT: (((((
|
|
|
|
; CHECK: %tmp20 = add i32 %tmp19, %x
|
|
|
|
|
|
|
|
bb:
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb1: ; preds = %bb3, %bb
|
|
|
|
%tmp = phi i64 [ %y, %bb ], [ %tmp22, %bb3 ]
|
|
|
|
%tmp2 = phi i32 [ %x, %bb ], [ %tmp4, %bb3 ]
|
|
|
|
br label %bb5
|
|
|
|
|
|
|
|
bb3: ; preds = %bb5
|
|
|
|
%tmp4 = add i32 %tmp2, %x
|
|
|
|
br label %bb1
|
|
|
|
|
|
|
|
bb5: ; preds = %bb5, %bb1
|
|
|
|
%tmp6 = phi i32 [ %tmp23, %bb5 ], [ %tmp2, %bb1 ]
|
|
|
|
%tmp7 = sub i32 -119, %tmp6
|
|
|
|
%tmp8 = mul i32 %tmp7, %x
|
|
|
|
%tmp9 = sub i32 -120, %tmp6
|
|
|
|
%tmp10 = mul i32 %tmp8, %tmp9
|
|
|
|
%tmp11 = mul i32 %x, %tmp10
|
|
|
|
%tmp12 = sub i32 -121, %tmp6
|
|
|
|
%tmp13 = mul i32 %tmp10, %tmp12
|
|
|
|
%tmp14 = mul i32 %tmp11, %tmp13
|
|
|
|
%tmp15 = sub i32 -122, %tmp6
|
|
|
|
%tmp16 = mul i32 %tmp13, %tmp15
|
|
|
|
%tmp17 = mul i32 %tmp14, %tmp16
|
|
|
|
%tmp18 = mul i32 %tmp16, %x
|
|
|
|
%tmp19 = mul i32 %tmp17, %tmp18
|
|
|
|
%tmp20 = add i32 %tmp19, %x
|
|
|
|
%tmp21 = sext i32 %tmp20 to i64
|
|
|
|
%tmp22 = add i64 %y, %tmp21
|
|
|
|
%tmp23 = add i32 %tmp6, 7
|
|
|
|
br i1 %cond, label %bb5, label %bb3
|
|
|
|
}
|