[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-16 11:09:47 -07: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
|
2015-02-18 01:47:07 +00:00
|
|
|
|
2016-05-29 00:32:17 +00:00
|
|
|
define void @infer.sext.0(i1* %c, i32 %start, i32* %buf) {
|
2015-02-18 01:47:07 +00:00
|
|
|
; CHECK-LABEL: Classifying expressions for: @infer.sext.0
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
2015-02-24 01:02:42 +00:00
|
|
|
%counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
|
2015-02-18 01:47:07 +00:00
|
|
|
%idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
|
|
|
|
%idx.inc = add nsw i32 %idx, 1
|
|
|
|
%idx.inc.sext = sext i32 %idx.inc to i64
|
|
|
|
; CHECK: %idx.inc.sext = sext i32 %idx.inc to i64
|
2015-10-22 19:57:19 +00:00
|
|
|
; CHECK-NEXT: --> {(1 + (sext i32 %start to i64))<nsw>,+,1}<nsw><%loop>
|
2016-05-29 00:32:17 +00:00
|
|
|
|
|
|
|
%buf.gep = getelementptr inbounds i32, i32* %buf, i32 %idx.inc
|
|
|
|
%val = load i32, i32* %buf.gep
|
|
|
|
|
2015-02-24 01:02:42 +00:00
|
|
|
%condition = icmp eq i32 %counter, 1
|
|
|
|
%counter.inc = add i32 %counter, 1
|
2015-02-18 01:47:07 +00:00
|
|
|
br i1 %condition, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-05-29 00:32:17 +00:00
|
|
|
define void @infer.zext.0(i1* %c, i32 %start, i32* %buf) {
|
2015-02-18 01:47:07 +00:00
|
|
|
; CHECK-LABEL: Classifying expressions for: @infer.zext.0
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
2015-02-24 01:02:42 +00:00
|
|
|
%counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
|
2015-02-18 01:47:07 +00:00
|
|
|
%idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
|
|
|
|
%idx.inc = add nuw i32 %idx, 1
|
|
|
|
%idx.inc.sext = zext i32 %idx.inc to i64
|
|
|
|
; CHECK: %idx.inc.sext = zext i32 %idx.inc to i64
|
2015-10-22 19:57:19 +00:00
|
|
|
; CHECK-NEXT: --> {(1 + (zext i32 %start to i64))<nuw><nsw>,+,1}<nuw><%loop>
|
2016-05-29 00:32:17 +00:00
|
|
|
|
|
|
|
%buf.gep = getelementptr inbounds i32, i32* %buf, i32 %idx.inc
|
|
|
|
%val = load i32, i32* %buf.gep
|
|
|
|
|
2015-02-24 01:02:42 +00:00
|
|
|
%condition = icmp eq i32 %counter, 1
|
|
|
|
%counter.inc = add i32 %counter, 1
|
2015-02-18 01:47:07 +00:00
|
|
|
br i1 %condition, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @infer.sext.1(i32 %start, i1* %c) {
|
|
|
|
; CHECK-LABEL: Classifying expressions for: @infer.sext.1
|
|
|
|
entry:
|
|
|
|
%start.mul = mul i32 %start, 4
|
|
|
|
%start.real = add i32 %start.mul, 2
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%idx = phi i32 [ %start.real, %entry ], [ %idx.inc, %loop ]
|
|
|
|
%idx.sext = sext i32 %idx to i64
|
|
|
|
; CHECK: %idx.sext = sext i32 %idx to i64
|
2019-06-15 09:15:52 +00:00
|
|
|
; CHECK-NEXT: --> {(2 + (sext i32 (4 * %start) to i64))<nuw><nsw>,+,2}<nsw><%loop>
|
2015-02-18 01:47:07 +00:00
|
|
|
%idx.inc = add nsw i32 %idx, 2
|
2015-02-27 21:17:42 +00:00
|
|
|
%condition = load i1, i1* %c
|
2015-02-18 01:47:07 +00:00
|
|
|
br i1 %condition, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @infer.sext.2(i1* %c, i8 %start) {
|
|
|
|
; CHECK-LABEL: Classifying expressions for: @infer.sext.2
|
|
|
|
entry:
|
|
|
|
%start.inc = add i8 %start, 1
|
|
|
|
%entry.condition = icmp slt i8 %start, 127
|
|
|
|
br i1 %entry.condition, label %loop, label %exit
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ]
|
|
|
|
%idx.sext = sext i8 %idx to i16
|
|
|
|
; CHECK: %idx.sext = sext i8 %idx to i16
|
2015-10-22 19:57:19 +00:00
|
|
|
; CHECK-NEXT: --> {(1 + (sext i8 %start to i16))<nsw>,+,1}<nsw><%loop>
|
2015-02-18 01:47:07 +00:00
|
|
|
%idx.inc = add nsw i8 %idx, 1
|
2015-02-27 21:17:42 +00:00
|
|
|
%condition = load volatile i1, i1* %c
|
2015-02-18 01:47:07 +00:00
|
|
|
br i1 %condition, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @infer.zext.1(i1* %c, i8 %start) {
|
|
|
|
; CHECK-LABEL: Classifying expressions for: @infer.zext.1
|
|
|
|
entry:
|
|
|
|
%start.inc = add i8 %start, 1
|
|
|
|
%entry.condition = icmp ult i8 %start, 255
|
|
|
|
br i1 %entry.condition, label %loop, label %exit
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%idx = phi i8 [ %start.inc, %entry ], [ %idx.inc, %loop ]
|
|
|
|
%idx.zext = zext i8 %idx to i16
|
|
|
|
; CHECK: %idx.zext = zext i8 %idx to i16
|
2015-10-22 19:57:19 +00:00
|
|
|
; CHECK-NEXT: --> {(1 + (zext i8 %start to i16))<nuw><nsw>,+,1}<nuw><%loop>
|
2015-02-18 01:47:07 +00:00
|
|
|
%idx.inc = add nuw i8 %idx, 1
|
2015-02-27 21:17:42 +00:00
|
|
|
%condition = load volatile i1, i1* %c
|
2015-02-18 01:47:07 +00:00
|
|
|
br i1 %condition, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|