1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/test/Analysis/ScalarEvolution/overflow-intrinsics-trip-count.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

130 lines
5.1 KiB
LLVM

; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
declare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone
declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone
declare { i16, i1 } @llvm.usub.with.overflow.i16(i16, i16) nounwind readnone
declare { i16, i1 } @llvm.smul.with.overflow.i16(i16, i16) nounwind readnone
declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16) nounwind readnone
; CHECK-LABEL: Classifying expressions for: @uadd_exhaustive
; CHECK: Loop %for.body: backedge-taken count is 35
define void @uadd_exhaustive() {
entry:
br i1 undef, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i16 [ %math, %for.body ], [ 65500, %for.body.preheader ]
%0 = call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %indvars.iv, i16 1)
%math = extractvalue { i16, i1 } %0, 0
%ov = extractvalue { i16, i1 } %0, 1
br i1 %ov, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: Classifying expressions for: @sadd_exhaustive
; CHECK: Loop %for.body: backedge-taken count is 67
define void @sadd_exhaustive() {
entry:
br i1 undef, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i16 [ %math, %for.body ], [ 32700, %for.body.preheader ]
%0 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 %indvars.iv, i16 1)
%math = extractvalue { i16, i1 } %0, 0
%ov = extractvalue { i16, i1 } %0, 1
br i1 %ov, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: Classifying expressions for: @usub_exhaustive
; CHECK: Loop %for.body: backedge-taken count is 50
define void @usub_exhaustive() {
entry:
br i1 undef, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i16 [ %math, %for.body ], [ 50, %for.body.preheader ]
%0 = call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %indvars.iv, i16 1)
%math = extractvalue { i16, i1 } %0, 0
%ov = extractvalue { i16, i1 } %0, 1
br i1 %ov, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: Classifying expressions for: @ssub_exhaustive
; CHECK: Loop %for.body: backedge-taken count is 68
define void @ssub_exhaustive() {
entry:
br i1 undef, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i16 [ %math, %for.body ], [ -32700, %for.body.preheader ]
%0 = call { i16, i1 } @llvm.ssub.with.overflow.i16(i16 %indvars.iv, i16 1)
%math = extractvalue { i16, i1 } %0, 0
%ov = extractvalue { i16, i1 } %0, 1
br i1 %ov, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: Classifying expressions for: @smul_exhaustive
; CHECK: Loop %for.body: backedge-taken count is 14
define void @smul_exhaustive() {
entry:
br i1 undef, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i16 [ %math, %for.body ], [ 1, %for.body.preheader ]
%0 = call { i16, i1 } @llvm.smul.with.overflow.i16(i16 %indvars.iv, i16 2)
%math = extractvalue { i16, i1 } %0, 0
%ov = extractvalue { i16, i1 } %0, 1
br i1 %ov, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}
; CHECK-LABEL: Classifying expressions for: @umul_exhaustive
; CHECK: Loop %for.body: backedge-taken count is 15
define void @umul_exhaustive() {
entry:
br i1 undef, label %for.end, label %for.body.preheader
for.body.preheader: ; preds = %entry
br label %for.body
for.body: ; preds = %for.body.preheader, %for.body
%indvars.iv = phi i16 [ %math, %for.body ], [ 1, %for.body.preheader ]
%0 = call { i16, i1 } @llvm.umul.with.overflow.i16(i16 %indvars.iv, i16 2)
%math = extractvalue { i16, i1 } %0, 0
%ov = extractvalue { i16, i1 } %0, 1
br i1 %ov, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}