2021-09-27 17:55:31 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
|
[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 < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
|
2018-03-01 14:56:48 +08:00
|
|
|
|
|
|
|
define void @merge_values_with_ranges(i32 *%a_len_ptr, i32 *%b_len_ptr, i1 %unknown_cond) {
|
2021-09-27 17:55:31 +08:00
|
|
|
; CHECK-LABEL: 'merge_values_with_ranges'
|
|
|
|
; CHECK-NEXT: Classifying expressions for: @merge_values_with_ranges
|
|
|
|
; CHECK-NEXT: %len_a = load i32, i32* %a_len_ptr, align 4, !range !0
|
|
|
|
; CHECK-NEXT: --> %len_a U: [0,2147483647) S: [0,2147483647)
|
|
|
|
; CHECK-NEXT: %len_b = load i32, i32* %b_len_ptr, align 4, !range !0
|
|
|
|
; CHECK-NEXT: --> %len_b U: [0,2147483647) S: [0,2147483647)
|
|
|
|
; CHECK-NEXT: %len = phi i32 [ %len_a, %if.true ], [ %len_b, %if.false ]
|
|
|
|
; CHECK-NEXT: --> %len U: [0,2147483647) S: [0,2147483647)
|
|
|
|
; CHECK-NEXT: Determining loop execution counts for: @merge_values_with_ranges
|
|
|
|
;
|
2018-03-01 14:56:48 +08:00
|
|
|
|
2021-09-27 17:55:31 +08:00
|
|
|
entry:
|
2018-03-01 14:56:48 +08:00
|
|
|
br i1 %unknown_cond, label %if.true, label %if.false
|
|
|
|
|
|
|
|
if.true:
|
|
|
|
%len_a = load i32, i32* %a_len_ptr, !range !0
|
|
|
|
br label %merge
|
|
|
|
|
|
|
|
if.false:
|
|
|
|
%len_b = load i32, i32* %b_len_ptr, !range !0
|
|
|
|
br label %merge
|
|
|
|
|
|
|
|
merge:
|
|
|
|
%len = phi i32 [ %len_a, %if.true ], [ %len_b, %if.false ]
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @merge_values_with_ranges_looped(i32 *%a_len_ptr, i32 *%b_len_ptr) {
|
2022-03-04 08:30:30 +08:00
|
|
|
; TODO: We could be much smarter here. So far we just make sure that we do not
|
|
|
|
; go into infinite loop analyzing these Phis.
|
2021-09-27 17:55:31 +08:00
|
|
|
; CHECK-LABEL: 'merge_values_with_ranges_looped'
|
|
|
|
; CHECK-NEXT: Classifying expressions for: @merge_values_with_ranges_looped
|
|
|
|
; CHECK-NEXT: %len_a = load i32, i32* %a_len_ptr, align 4, !range !0
|
|
|
|
; CHECK-NEXT: --> %len_a U: [0,2147483647) S: [0,2147483647)
|
|
|
|
; CHECK-NEXT: %len_b = load i32, i32* %b_len_ptr, align 4, !range !0
|
|
|
|
; CHECK-NEXT: --> %len_b U: [0,2147483647) S: [0,2147483647)
|
|
|
|
; CHECK-NEXT: %p1 = phi i32 [ %len_a, %entry ], [ %p2, %loop ]
|
2022-03-04 08:30:30 +08:00
|
|
|
; CHECK-NEXT: --> %p1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
|
2021-09-27 17:55:31 +08:00
|
|
|
; CHECK-NEXT: %p2 = phi i32 [ %len_b, %entry ], [ %p1, %loop ]
|
2022-03-04 08:30:30 +08:00
|
|
|
; CHECK-NEXT: --> %p2 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Variant }
|
2021-09-27 17:55:31 +08:00
|
|
|
; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
|
|
|
|
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,100) S: [0,100) Exits: 99 LoopDispositions: { %loop: Computable }
|
|
|
|
; CHECK-NEXT: %iv.next = add i32 %iv, 1
|
|
|
|
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,101) S: [1,101) Exits: 100 LoopDispositions: { %loop: Computable }
|
|
|
|
; CHECK-NEXT: Determining loop execution counts for: @merge_values_with_ranges_looped
|
|
|
|
; CHECK-NEXT: Loop %loop: backedge-taken count is 99
|
|
|
|
; CHECK-NEXT: Loop %loop: max backedge-taken count is 99
|
|
|
|
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is 99
|
|
|
|
; CHECK-NEXT: Predicates:
|
|
|
|
; CHECK: Loop %loop: Trip multiple is 100
|
|
|
|
;
|
2018-03-01 14:56:48 +08:00
|
|
|
|
2021-09-27 17:55:31 +08:00
|
|
|
entry:
|
2018-03-01 14:56:48 +08:00
|
|
|
%len_a = load i32, i32* %a_len_ptr, !range !0
|
|
|
|
%len_b = load i32, i32* %b_len_ptr, !range !0
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%p1 = phi i32 [ %len_a, %entry ], [ %p2, %loop ]
|
|
|
|
%p2 = phi i32 [ %len_b, %entry ], [ %p1, %loop ]
|
|
|
|
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
|
|
|
|
%iv.next = add i32 %iv, 1
|
|
|
|
%loop.cond = icmp slt i32 %iv.next, 100
|
|
|
|
br i1 %loop.cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
!0 = !{i32 0, i32 2147483647}
|