1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/pr24757.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

37 lines
1.0 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
; CHECK: Loop %bb1: backedge-taken count is ((2 * %a.promoted) /u 2)
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
@a = global i8 -127, align 1
@b = common global i32 0, align 4
declare void @use(i32)
define i32 @main() {
bb:
%a.promoted = load i8, i8* @a
br label %bb1
bb1: ; preds = %bb1, %bb
%tmp = phi i8 [ %tmp2, %bb1 ], [ %a.promoted, %bb ]
%tmp2 = add i8 %tmp, -1
%tmp3 = sext i8 %tmp to i32
%tmp4 = xor i32 %tmp3, -1
%tmp5 = sext i8 %tmp2 to i32
%tmpf = sub nsw i32 %tmp4, %tmp5
%tmp6 = trunc i32 %tmpf to i8
%tmp7 = icmp eq i8 %tmp6, 0
br i1 %tmp7, label %bb8, label %bb1
bb8: ; preds = %bb1
store i8 %tmp2, i8* @a
store i32 %tmp4, i32* @b
%tmp9 = sext i8 %tmp2 to i32
call void @use(i32 %tmp9)
ret i32 0
}