[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 20:09:47 +02:00
|
|
|
; 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
|
2018-06-08 22:43:07 +02:00
|
|
|
|
|
|
|
; The initial SCEV for the backedge count is
|
|
|
|
; (zext i2 {(trunc i32 (1 + %a1) to i2),+,1}<%b2> to i32).
|
|
|
|
; In howFarToZero, this was further converted to an add-rec, the complexity
|
|
|
|
; of which defeated the calculation of the backedge taken count.
|
|
|
|
; Since such zero-extensions preserve the values being extended, strip
|
|
|
|
; them in howFarToZero to simplify the input SCEV.
|
|
|
|
|
|
|
|
; Check that the backedge taken count was actually computed:
|
|
|
|
; CHECK: Determining loop execution counts for: @f0
|
2018-06-14 19:13:35 +02:00
|
|
|
; CHECK-NEXT: Loop %b2: backedge-taken count is (-1 + (-1 * (trunc i32 %a1 to i2)))
|
2018-06-08 22:43:07 +02:00
|
|
|
|
|
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
|
|
|
|
|
|
|
|
define i32 @f0(i32 %a0, i32 %a1, i32* nocapture %a2) #0 {
|
|
|
|
b0:
|
|
|
|
%v0 = and i32 %a1, 3
|
|
|
|
%v1 = icmp eq i32 %v0, 0
|
|
|
|
br i1 %v1, label %b4, label %b1
|
|
|
|
|
|
|
|
b1: ; preds = %b0
|
|
|
|
%v2 = shl i32 %a0, 7
|
|
|
|
%v3 = add i32 %v2, -128
|
|
|
|
br label %b2
|
|
|
|
|
|
|
|
b2: ; preds = %b2, %b1
|
|
|
|
%v4 = phi i32 [ %a1, %b1 ], [ %v9, %b2 ]
|
|
|
|
%v5 = phi i32* [ %a2, %b1 ], [ %v8, %b2 ]
|
|
|
|
%v6 = getelementptr inbounds i32, i32* %v5, i32 0
|
|
|
|
store i32 %v3, i32* %v6, align 4
|
|
|
|
%v8 = getelementptr inbounds i32, i32* %v5, i32 1
|
|
|
|
%v9 = add nsw i32 %v4, 1
|
|
|
|
%v10 = and i32 %v9, 3
|
|
|
|
%v11 = icmp eq i32 %v10, 0
|
|
|
|
br i1 %v11, label %b3, label %b2
|
|
|
|
|
|
|
|
b3: ; preds = %b2
|
|
|
|
br label %b4
|
|
|
|
|
|
|
|
b4: ; preds = %b3, %b0
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { norecurse nounwind }
|