1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/trip-count13.ll
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

83 lines
2.6 KiB
LLVM

; 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 @u_0(i8 %rhs) {
; E.g.: %rhs = 255, %start = 99, backedge taken 156 times
entry:
%start = add i8 %rhs, 100
br label %loop
loop:
%iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
%iv.inc = add nuw i8 %iv, 1 ;; Note: this never unsigned-wraps
%iv.cmp = icmp ult i8 %iv, %rhs
br i1 %iv.cmp, label %loop, label %leave
; CHECK-LABEL: Determining loop execution counts for: @u_0
; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) umax %rhs))
; CHECK-NEXT: Loop %loop: max backedge-taken count is -100, actual taken count either this or zero.
leave:
ret void
}
define void @u_1(i8 %start) {
entry:
; E.g.: %start = 99, %rhs = 255, backedge taken 156 times
%rhs = add i8 %start, -100
br label %loop
loop:
%iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
%iv.inc = add nuw i8 %iv, 1 ;; Note: this never unsigned-wraps
%iv.cmp = icmp ult i8 %iv, %rhs
br i1 %iv.cmp, label %loop, label %leave
; CHECK-LABEL: Determining loop execution counts for: @u_1
; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) umax %start))
; CHECK-NEXT: Loop %loop: max backedge-taken count is -100, actual taken count either this or zero.
leave:
ret void
}
define void @s_0(i8 %rhs) {
entry:
; E.g.: %rhs = 127, %start = -29, backedge taken 156 times
%start = add i8 %rhs, 100
br label %loop
loop:
%iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
%iv.inc = add nsw i8 %iv, 1 ;; Note: this never signed-wraps
%iv.cmp = icmp slt i8 %iv, %rhs
br i1 %iv.cmp, label %loop, label %leave
; CHECK-LABEL: Determining loop execution counts for: @s_0
; CHECK-NEXT: Loop %loop: backedge-taken count is (-100 + (-1 * %rhs) + ((100 + %rhs) smax %rhs))
; CHECK-NEXT: Loop %loop: max backedge-taken count is -100, actual taken count either this or zero.
leave:
ret void
}
define void @s_1(i8 %start) {
entry:
; E.g.: start = -29, %rhs = 127, %backedge taken 156 times
%rhs = add i8 %start, -100
br label %loop
loop:
%iv = phi i8 [ %start, %entry ], [ %iv.inc, %loop ]
%iv.inc = add nsw i8 %iv, 1
%iv.cmp = icmp slt i8 %iv, %rhs
br i1 %iv.cmp, label %loop, label %leave
; CHECK-LABEL: Determining loop execution counts for: @s_1
; CHECK-NEXT: Loop %loop: backedge-taken count is ((-1 * %start) + ((-100 + %start) smax %start))
; CHECK-NEXT: Loop %loop: max backedge-taken count is -100, actual taken count either this or zero.
leave:
ret void
}