mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-12 07:37:34 +00:00
New testcases for the indvars pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
45a0a61534
commit
788aed9146
23
test/Transforms/IndVarsSimplify/lftr_simple.llx
Normal file
23
test/Transforms/IndVarsSimplify/lftr_simple.llx
Normal file
@ -0,0 +1,23 @@
|
||||
; LFTR should eliminate the need for the computation of i*i completely. It
|
||||
; is only used to compute the exit value.
|
||||
; RUN: llvm-as < %s | opt -indvars -dce | llvm-dis | not grep mul
|
||||
|
||||
%A = external global int
|
||||
|
||||
implementation
|
||||
|
||||
int %quadratic_setlt() { ;; for (i = 7; i*i < 1000; ++i)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 7, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 1
|
||||
store int %i, int* %A
|
||||
|
||||
%i2 = mul int %i, %i
|
||||
%c = setlt int %i2, 1000
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
90
test/Transforms/IndVarsSimplify/tripcount_compute.llx
Normal file
90
test/Transforms/IndVarsSimplify/tripcount_compute.llx
Normal file
@ -0,0 +1,90 @@
|
||||
; These tests ensure that we can compute the trip count of various forms of
|
||||
; loops. If the trip count of the loop is computable, then we will know what
|
||||
; the exit value of the loop will be for some value, allowing us to substitute
|
||||
; it directly into users outside of the loop, making the loop dead.
|
||||
;
|
||||
; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | not grep br
|
||||
|
||||
int %linear_setne() { ;; for (i = 0; i != 100; ++i)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 0, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 1
|
||||
%c = setne int %i, 100
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
||||
int %linear_setne_2() { ;; for (i = 0; i != 100; i += 2)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 0, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 2
|
||||
%c = setne int %i, 100
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
||||
|
||||
int %linear_setne_overflow() { ;; for (i = 1024; i != 0; i += 1024)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 1024, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 1024
|
||||
%c = setne int %i, 0
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
||||
int %linear_setlt() { ;; for (i = 0; i < 100; ++i)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 0, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 1
|
||||
%c = setlt int %i, 100
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
||||
int %quadratic_setlt() { ;; for (i = 7; i*i < 1000; i+=3)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 7, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 3
|
||||
%i2 = mul int %i, %i
|
||||
%c = setlt int %i2, 1000
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
||||
;; Chained loop test - The exit value of the second loop depends on the exit
|
||||
;; value of the first being computed.
|
||||
int %chained() {
|
||||
entry:
|
||||
br label %loop
|
||||
loop: ;; for (i = 0; i != 100; ++i)
|
||||
%i = phi int [ 0, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 1
|
||||
%c = setne int %i, 100
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
br label %loop2
|
||||
loop2: ;; for (j = i; j != 200; ++j)
|
||||
%j = phi int [ %i, %loopexit ], [ %j.next, %loop2 ]
|
||||
%j.next = add int %j, 1
|
||||
%c2 = setne int %j, 200
|
||||
br bool %c2, label %loop2, label %loopexit2
|
||||
loopexit2:
|
||||
ret int %j
|
||||
}
|
||||
|
32
test/Transforms/IndVarsSimplify/tripcount_infinite.llx
Normal file
32
test/Transforms/IndVarsSimplify/tripcount_infinite.llx
Normal file
@ -0,0 +1,32 @@
|
||||
; These tests have an infinite trip count. We obviously shouldn't remove the
|
||||
; loops! :)
|
||||
;
|
||||
; RUN: llvm-as < %s | opt -indvars -adce -simplifycfg | llvm-dis | grep set | wc -l > %t2
|
||||
; RUN: llvm-as < %s | llvm-dis | grep set | wc -l > %t1
|
||||
; RUN: diff %t1 %t2
|
||||
|
||||
int %infinite_linear() { ;; test for (i = 1; i != 100; i += 2)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 1, %entry ], [ %i.next, %loop ]
|
||||
%i.next = add int %i, 2
|
||||
%c = setne int %i, 100
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
||||
int %infinite_quadratic() { ;; test for (i = 1; i*i != 63; ++i)
|
||||
entry:
|
||||
br label %loop
|
||||
loop:
|
||||
%i = phi int [ 1, %entry ], [ %i.next, %loop ]
|
||||
%isquare = mul int %i, %i
|
||||
%i.next = add int %i, 1
|
||||
%c = setne int %isquare, 63
|
||||
br bool %c, label %loop, label %loopexit
|
||||
loopexit:
|
||||
ret int %i
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user