1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/scev-dispositions.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

75 lines
2.5 KiB
LLVM

; 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
define void @single_loop(i32* %buf, i32 %start) {
; CHECK-LABEL: Classifying expressions for: @single_loop
entry:
%val = add i32 %start, 400
br label %loop
loop:
%counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
%idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
; CHECK: %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %loop: Computable }
; CHECK: %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %loop: Computable }
; CHECK: %val2 = add i32 %start, 400
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %loop: Invariant }
; CHECK: %idx.inc = add nsw i32 %idx, 1
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %loop: Computable }
; CHECK: %val3 = load volatile i32, i32* %buf
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %loop: Variant }
%val2 = add i32 %start, 400
%idx.inc = add nsw i32 %idx, 1
%idx.inc.sext = sext i32 %idx.inc to i64
%condition = icmp eq i32 %counter, 1
%counter.inc = add i32 %counter, 1
%val3 = load volatile i32, i32* %buf
br i1 %condition, label %exit, label %loop
exit:
ret void
}
define void @nested_loop(double* %p, i64 %m) {
; CHECK-LABEL: Classifying expressions for: @nested_loop
; CHECK: %j = phi i64 [ 0, %entry ], [ %j.next, %outer.latch ]
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %outer.loop: Computable, %bb: Invariant }
; CHECK: %i = phi i64 [ 0, %outer.loop ], [ %i.next, %bb ]
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %bb: Computable, %outer.loop: Variant }
; CHECK: %j.add = add i64 %j, 100
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %bb: Invariant, %outer.loop: Computable }
; CHECK: %i.next = add i64 %i, 1
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %bb: Computable, %outer.loop: Variant }
; CHECK: %j.next = add i64 %j, 91
; CHECK-NEXT: --> {{.*}} LoopDispositions: { %outer.loop: Computable, %bb: Invariant }
entry:
%k = icmp sgt i64 %m, 0
br i1 %k, label %outer.loop, label %return
outer.loop:
%j = phi i64 [ 0, %entry ], [ %j.next, %outer.latch ]
br label %bb
bb:
%i = phi i64 [ 0, %outer.loop ], [ %i.next, %bb ]
%j.add = add i64 %j, 100
%i.next = add i64 %i, 1
%exitcond = icmp eq i64 %i.next, 91
br i1 %exitcond, label %outer.latch, label %bb
outer.latch:
%j.next = add i64 %j, 91
%h = icmp eq i64 %j.next, %m
br i1 %h, label %return, label %outer.loop
return:
ret void
}