[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-17 02:09:47 +08:00
|
|
|
; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution -S < %s | FileCheck %s
|
|
|
|
; RUN: opt -disable-output "-passes=print<scalar-evolution>" -S < %s 2>&1 | FileCheck %s
|
2018-08-03 03:13:35 +08:00
|
|
|
|
|
|
|
; The exit value from this loop was originally calculated as 0.
|
|
|
|
; The actual exit condition is 256*256 == 0 (in i16).
|
|
|
|
|
|
|
|
; CHECK: Printing analysis 'Scalar Evolution Analysis' for function 'f0':
|
|
|
|
; CHECK-NEXT: Classifying expressions for: @f0
|
|
|
|
; CHECK-NEXT: %v1 = phi i16 [ 0, %b0 ], [ %v2, %b1 ]
|
|
|
|
; CHECK-NEXT: --> {0,+,-1}<%b1> U: [-255,1) S: [-255,1) Exits: -255 LoopDispositions: { %b1: Computable }
|
|
|
|
; CHECK-NEXT: %v2 = add i16 %v1, -1
|
|
|
|
; CHECK-NEXT: --> {-1,+,-1}<%b1> U: [-256,0) S: [-256,0) Exits: -256 LoopDispositions: { %b1: Computable }
|
|
|
|
; CHECK-NEXT: %v3 = mul i16 %v2, %v2
|
|
|
|
; CHECK-NEXT: --> {1,+,3,+,2}<%b1> U: full-set S: full-set Exits: 0 LoopDispositions: { %b1: Computable }
|
|
|
|
; CHECK-NEXT: %v5 = phi i16 [ %v2, %b1 ]
|
Revert "[SCEV] Look through single value PHIs."
This reverts commit e441b7a7a0a72c28daf5a8e594559c667e5b4534.
This patch causes a compile error in tensorflow opensource project. The stack trace looks like:
Point of crash:
llvm/include/llvm/Analysis/LoopInfoImpl.h : line 35
(gdb) ptype *this
type = const class llvm::LoopBase<llvm::BasicBlock, llvm::Loop> [with BlockT = llvm::BasicBlock, LoopT = llvm::Loop]
(gdb) p *this
$1 = {ParentLoop = 0x0, SubLoops = std::vector of length 0, capacity 0, Blocks = std::vector of length 0, capacity 1,
DenseBlockSet = {<llvm::SmallPtrSetImpl<llvm::BasicBlock const*>> = {<llvm::SmallPtrSetImplBase> = {<llvm::DebugEpochBase> = {Epoch = 3}, SmallArray = 0x1b2bf6c8, CurArray = 0x1b2bf6c8,
CurArraySize = 8, NumNonEmpty = 0, NumTombstones = 0}, <No data fields>}, SmallStorage = {0xfffffffffffffffe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsInvalid = true}
(gdb) p *this->DenseBlockSet->CurArray
$2 = (const void *) 0xfffffffffffffffe
I will try to get a case from tensorflow or use creduce to get a small case.
2020-08-13 14:02:17 +08:00
|
|
|
; CHECK-NEXT: --> %v5 U: [-256,0) S: [-256,0)
|
2018-08-03 03:13:35 +08:00
|
|
|
; CHECK-NEXT: %v6 = phi i16 [ %v3, %b1 ]
|
Revert "[SCEV] Look through single value PHIs."
This reverts commit e441b7a7a0a72c28daf5a8e594559c667e5b4534.
This patch causes a compile error in tensorflow opensource project. The stack trace looks like:
Point of crash:
llvm/include/llvm/Analysis/LoopInfoImpl.h : line 35
(gdb) ptype *this
type = const class llvm::LoopBase<llvm::BasicBlock, llvm::Loop> [with BlockT = llvm::BasicBlock, LoopT = llvm::Loop]
(gdb) p *this
$1 = {ParentLoop = 0x0, SubLoops = std::vector of length 0, capacity 0, Blocks = std::vector of length 0, capacity 1,
DenseBlockSet = {<llvm::SmallPtrSetImpl<llvm::BasicBlock const*>> = {<llvm::SmallPtrSetImplBase> = {<llvm::DebugEpochBase> = {Epoch = 3}, SmallArray = 0x1b2bf6c8, CurArray = 0x1b2bf6c8,
CurArraySize = 8, NumNonEmpty = 0, NumTombstones = 0}, <No data fields>}, SmallStorage = {0xfffffffffffffffe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsInvalid = true}
(gdb) p *this->DenseBlockSet->CurArray
$2 = (const void *) 0xfffffffffffffffe
I will try to get a case from tensorflow or use creduce to get a small case.
2020-08-13 14:02:17 +08:00
|
|
|
; CHECK-NEXT: --> %v6 U: full-set S: full-set
|
2018-08-03 03:13:35 +08:00
|
|
|
; CHECK-NEXT: %v7 = sext i16 %v5 to i32
|
Revert "[SCEV] Look through single value PHIs."
This reverts commit e441b7a7a0a72c28daf5a8e594559c667e5b4534.
This patch causes a compile error in tensorflow opensource project. The stack trace looks like:
Point of crash:
llvm/include/llvm/Analysis/LoopInfoImpl.h : line 35
(gdb) ptype *this
type = const class llvm::LoopBase<llvm::BasicBlock, llvm::Loop> [with BlockT = llvm::BasicBlock, LoopT = llvm::Loop]
(gdb) p *this
$1 = {ParentLoop = 0x0, SubLoops = std::vector of length 0, capacity 0, Blocks = std::vector of length 0, capacity 1,
DenseBlockSet = {<llvm::SmallPtrSetImpl<llvm::BasicBlock const*>> = {<llvm::SmallPtrSetImplBase> = {<llvm::DebugEpochBase> = {Epoch = 3}, SmallArray = 0x1b2bf6c8, CurArray = 0x1b2bf6c8,
CurArraySize = 8, NumNonEmpty = 0, NumTombstones = 0}, <No data fields>}, SmallStorage = {0xfffffffffffffffe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, IsInvalid = true}
(gdb) p *this->DenseBlockSet->CurArray
$2 = (const void *) 0xfffffffffffffffe
I will try to get a case from tensorflow or use creduce to get a small case.
2020-08-13 14:02:17 +08:00
|
|
|
; CHECK-NEXT: --> (sext i16 %v5 to i32) U: [-256,0) S: [-256,0)
|
2018-08-03 03:13:35 +08:00
|
|
|
; CHECK-NEXT: Determining loop execution counts for: @f0
|
|
|
|
; CHECK-NEXT: Loop %b1: backedge-taken count is 255
|
|
|
|
; CHECK-NEXT: Loop %b1: max backedge-taken count is 255
|
|
|
|
; CHECK-NEXT: Loop %b1: Predicated backedge-taken count is 255
|
|
|
|
; CHECK-NEXT: Predicates:
|
|
|
|
; CHECK-EMPTY:
|
|
|
|
; CHECK-NEXT: Loop %b1: Trip multiple is 256
|
|
|
|
|
|
|
|
|
|
|
|
@g0 = global i32 0, align 4
|
|
|
|
@g1 = global i16 0, align 2
|
|
|
|
|
|
|
|
define signext i32 @f0() {
|
|
|
|
b0:
|
|
|
|
br label %b1
|
|
|
|
|
|
|
|
b1: ; preds = %b1, %b0
|
|
|
|
%v1 = phi i16 [ 0, %b0 ], [ %v2, %b1 ]
|
|
|
|
%v2 = add i16 %v1, -1
|
|
|
|
%v3 = mul i16 %v2, %v2
|
|
|
|
%v4 = icmp eq i16 %v3, 0
|
|
|
|
br i1 %v4, label %b2, label %b1
|
|
|
|
|
|
|
|
b2: ; preds = %b1
|
|
|
|
%v5 = phi i16 [ %v2, %b1 ]
|
|
|
|
%v6 = phi i16 [ %v3, %b1 ]
|
|
|
|
%v7 = sext i16 %v5 to i32
|
|
|
|
store i32 %v7, i32* @g0, align 4
|
|
|
|
store i16 %v6, i16* @g1, align 2
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|