1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/scev-prestart-nowrap.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

84 lines
2.4 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
; An example run where SCEV(%postinc)->getStart() may overflow:
;
; %start = INT_SMAX
; %low.limit = INT_SMIN
; %high.limit = < not used >
;
; >> entry:
; %postinc.start = INT_SMIN
;
; >> loop:
; %idx = %start
; %postinc = INT_SMIN
; %postinc.inc = INT_SMIN + 1
; %postinc.sext = sext(INT_SMIN) = i64 INT32_SMIN
; %break.early = INT_SMIN `slt` INT_SMIN = false
; br i1 false, ___, %early.exit
;
; >> early.exit:
; ret i64 INT32_SMIN
define i64 @bad.0(i32 %start, i32 %low.limit, i32 %high.limit) {
; CHECK-LABEL: Classifying expressions for: @bad.0
entry:
%postinc.start = add i32 %start, 1
br label %loop
loop:
%idx = phi i32 [ %start, %entry ], [ %idx.inc, %continue ]
%postinc = phi i32 [ %postinc.start, %entry ], [ %postinc.inc, %continue ]
%postinc.inc = add nsw i32 %postinc, 1
%postinc.sext = sext i32 %postinc to i64
; CHECK: %postinc.sext = sext i32 %postinc to i64
; CHECK-NEXT: --> {(sext i32 (1 + %start) to i64),+,1}<nsw><%loop>
%break.early = icmp slt i32 %postinc, %low.limit
br i1 %break.early, label %continue, label %early.exit
continue:
%idx.inc = add nsw i32 %idx, 1
%cmp = icmp slt i32 %idx.inc, %high.limit
br i1 %cmp, label %loop, label %exit
exit:
ret i64 0
early.exit:
ret i64 %postinc.sext
}
define i64 @bad.1(i32 %start, i32 %low.limit, i32 %high.limit, i1* %unknown) {
; CHECK-LABEL: Classifying expressions for: @bad.1
entry:
%postinc.start = add i32 %start, 1
br label %loop
loop:
%idx = phi i32 [ %start, %entry ], [ %idx.inc, %continue ], [ %idx.inc, %continue.1 ]
%postinc = phi i32 [ %postinc.start, %entry ], [ %postinc.inc, %continue ], [ %postinc.inc, %continue.1 ]
%postinc.inc = add nsw i32 %postinc, 1
%postinc.sext = sext i32 %postinc to i64
; CHECK: %postinc.sext = sext i32 %postinc to i64
; CHECK-NEXT: --> {(sext i32 (1 + %start) to i64),+,1}<nsw><%loop>
%break.early = icmp slt i32 %postinc, %low.limit
br i1 %break.early, label %continue.1, label %early.exit
continue.1:
%cond = load volatile i1, i1* %unknown
%idx.inc = add nsw i32 %idx, 1
br i1 %cond, label %loop, label %continue
continue:
%cmp = icmp slt i32 %idx.inc, %high.limit
br i1 %cmp, label %loop, label %exit
exit:
ret i64 0
early.exit:
ret i64 %postinc.sext
}