1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
Arthur Eubanks 09cfe7939a [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:24:07 -07:00

123 lines
5.4 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
; RUN: opt -S -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
define void @umin_unsigned_check(i64 %n) {
; CHECK-LABEL: 'umin_unsigned_check'
; CHECK-NEXT: Classifying expressions for: @umin_unsigned_check
; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
; CHECK-NEXT: --> (4096 umin %n) U: [0,4097) S: [0,4097)
; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4098) S: [0,4098) Exits: (1 + (4096 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add i64 %iv, 1
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4099) S: [1,4099) Exits: (2 + (4096 umin %n)) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @umin_unsigned_check
; CHECK-NEXT: Loop %loop: backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
; CHECK-NEXT: Loop %loop: max backedge-taken count is 4097
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
entry:
%min.cmp = icmp ult i64 4096, %n
%min.n = select i1 %min.cmp, i64 4096, i64 %n
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
%iv.next = add i64 %iv, 1
%exit = icmp ugt i64 %iv, %min.n
br i1 %exit, label %loop_exit, label %loop
loop_exit:
ret void
}
define void @umin_signed_check(i64 %n) {
; CHECK-LABEL: 'umin_signed_check'
; CHECK-NEXT: Classifying expressions for: @umin_signed_check
; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
; CHECK-NEXT: --> (4096 umin %n) U: [0,4097) S: [0,4097)
; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4098) S: [0,4098) Exits: (1 + (4096 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add i64 %iv, 1
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4099) S: [1,4099) Exits: (2 + (4096 umin %n)) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @umin_signed_check
; CHECK-NEXT: Loop %loop: backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
; CHECK-NEXT: Loop %loop: max backedge-taken count is 4097
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
entry:
%min.cmp = icmp ult i64 4096, %n
%min.n = select i1 %min.cmp, i64 4096, i64 %n
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
%iv.next = add i64 %iv, 1
%exit = icmp sgt i64 %iv, %min.n
br i1 %exit, label %loop_exit, label %loop
loop_exit:
ret void
}
define void @smin_signed_check(i64 %n) {
; CHECK-LABEL: 'smin_signed_check'
; CHECK-NEXT: Classifying expressions for: @smin_signed_check
; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
; CHECK-NEXT: --> (4096 smin %n) U: [-9223372036854775808,4097) S: [-9223372036854775808,4097)
; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4098) S: [0,4098) Exits: (0 smax (1 + (4096 smin %n))<nsw>) LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add i64 %iv, 1
; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4099) S: [1,4099) Exits: (1 + (0 smax (1 + (4096 smin %n))<nsw>))<nuw><nsw> LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @smin_signed_check
; CHECK-NEXT: Loop %loop: backedge-taken count is (0 smax (1 + (4096 smin %n))<nsw>)
; CHECK-NEXT: Loop %loop: max backedge-taken count is 4097
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (0 smax (1 + (4096 smin %n))<nsw>)
; CHECK-NEXT: Predicates:
; CHECK: Loop %loop: Trip multiple is 1
;
entry:
%min.cmp = icmp slt i64 4096, %n
%min.n = select i1 %min.cmp, i64 4096, i64 %n
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
%iv.next = add i64 %iv, 1
%exit = icmp sgt i64 %iv, %min.n
br i1 %exit, label %loop_exit, label %loop
loop_exit:
ret void
}
define void @smin_unsigned_check(i64 %n) {
; CHECK-LABEL: 'smin_unsigned_check'
; CHECK-NEXT: Classifying expressions for: @smin_unsigned_check
; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
; CHECK-NEXT: --> (4096 smin %n) U: [-9223372036854775808,4097) S: [-9223372036854775808,4097)
; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
; CHECK-NEXT: %iv.next = add i64 %iv, 1
; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
; CHECK-NEXT: Determining loop execution counts for: @smin_unsigned_check
; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
;
entry:
%min.cmp = icmp slt i64 4096, %n
%min.n = select i1 %min.cmp, i64 4096, i64 %n
br label %loop
loop:
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
%iv.next = add i64 %iv, 1
%exit = icmp ugt i64 %iv, %min.n
br i1 %exit, label %loop_exit, label %loop
loop_exit:
ret void
}