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
37 lines
1.5 KiB
LLVM
37 lines
1.5 KiB
LLVM
; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
|
|
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
|
|
|
|
; CHECK: Determining loop execution counts for: @test
|
|
; CHECK: Loop %for.body: backedge-taken count is ((-2 + %len) /u 2)
|
|
; CHECK: Loop %for.body: max backedge-taken count is 1073741823
|
|
|
|
define zeroext i16 @test(i16* nocapture %p, i32 %len) nounwind readonly {
|
|
entry:
|
|
%cmp2 = icmp sgt i32 %len, 1
|
|
br i1 %cmp2, label %for.body.preheader, label %for.end
|
|
|
|
for.body.preheader: ; preds = %entry
|
|
br label %for.body
|
|
|
|
for.body: ; preds = %for.body, %for.body.preheader
|
|
%p.addr.05 = phi i16* [ %incdec.ptr, %for.body ], [ %p, %for.body.preheader ]
|
|
%len.addr.04 = phi i32 [ %sub, %for.body ], [ %len, %for.body.preheader ]
|
|
%res.03 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
|
|
%incdec.ptr = getelementptr inbounds i16, i16* %p.addr.05, i32 1
|
|
%0 = load i16, i16* %p.addr.05, align 2
|
|
%conv = zext i16 %0 to i32
|
|
%add = add i32 %conv, %res.03
|
|
%sub = add nsw i32 %len.addr.04, -2
|
|
%cmp = icmp sgt i32 %sub, 1
|
|
br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge
|
|
|
|
for.cond.for.end_crit_edge: ; preds = %for.body
|
|
%extract.t = trunc i32 %add to i16
|
|
br label %for.end
|
|
|
|
for.end: ; preds = %for.cond.for.end_crit_edge, %entry
|
|
%res.0.lcssa.off0 = phi i16 [ %extract.t, %for.cond.for.end_crit_edge ], [ 0, %entry ]
|
|
ret i16 %res.0.lcssa.off0
|
|
}
|
|
|