Skip to content

Constant propagation and inlining benchmarks #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Benchmarks for the CSCI 1260 final project
------------------------------------------

Open up a pull request on this repository to add a benchmark to the
`benchmarks/` directory.
1. `constprog_and_inline.lisp`: One function can be inlined, the other not, the inlined function should be much quicker after inlining is applied
2. `constprog_branches.lisp`: Constant propagation of a large number of let bound values
3. `multiple_inline.lisp:` Multiple functions that can be inlined
14 changes: 14 additions & 0 deletions benchmarks/constprog_and_inline.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(define (inl a b c) (
if (= (+ a b) c) (+ a b) (
- b c
)
))

(define (rec a b c) (if (zero? a) c (rec (- a 1) b (+ b c))))

(do
(print (rec 3 4 5))
(newline)
(print (inl 3 4 5))
)

51 changes: 51 additions & 0 deletions benchmarks/constprog_branches.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(let ((a 1))
(let ((b 2))
(let ((c 3))
(let ((d 4))
(let ((e 5))
(let ((f 6))
(let ((g 7))
(let ((h 8))
(let ((i 9))
(let ((j 10))
(let ((k 11))
(let ((l 12))
(let ((m 13))
(let ((n 14))
(let ((o 15))
(let ((p 16))
(let ((q 17))
(if (< a b)
(if (< b c) (
if (< c d) (
if (< d e) (
if (< e f) (
if (< f g) (
if (< g h) (
if (< h i) (
if (< i j) (
if (< j k) (
if (< k l) (
if (< l m) (
if (< m n) (
if (< n o) (
if (< o p) (
if (< p q) (
print true
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false)
) (print false))
)))))))))))))))))
2 changes: 0 additions & 2 deletions benchmarks/example.lisp

This file was deleted.

38 changes: 38 additions & 0 deletions benchmarks/multiple_inline.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(define (a x y) (+ x y))
(define (b x y) (- x y))
(define (d x y z) (+ x (+ y z)))
(define (e x y z) (- x (- y z)))
(define (f x y z) (- x (+ y z)))
(define (g x y z) (+ x (- y z)))
(define (j w x y z) (+ w (+ x (+ y z))))
(define (k w x y z) (- w (- x (- y z))))
(define (l w x y z) (+ w (- x (+ y z))))

(let ((dontconstprog (read-num))) (
let ((x 10)) (
let ((y 5)) (
let ((z 3)) (
let ((w 2)) (
print (k dontconstprog x y (
l w x y (
j z w y (
g x w (
f z x (
e w z (
d x y (
b dontconstprog (
a w x
)
)
)
)
)
)
)
))

)
)
)
)
))