Skip to content

Commit

Permalink
Add benchmark files
Browse files Browse the repository at this point in the history
  • Loading branch information
kirstenmg committed Jun 5, 2024
1 parent 56fec6a commit 1a952ad
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/passing/peggy_comparison/branch_hoisting.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ARGS: 0
@main(n: int): int {
zero: int = const 0;
x: int = id zero;
y: int = id zero;
fivehundred: int = const 500;

.pred:
whilecond: bool = lt y fivehundred;
br whilecond .loopbody .end;

.loopbody:
two: int = const 2;
ifcond: bool = eq n zero;
br ifcond .thn .els;

.thn:
x: int = mul y two;
jmp .ifend;

.els:
three: int = const 3;
x: int = mul y three;

.ifend:
one: int = const 1;
y: int = add one y;

jmp .pred;

.end:
ret x;
}
29 changes: 29 additions & 0 deletions tests/passing/peggy_comparison/conditional_constant_folding.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ARGS: 4
@main(x: int): int {
five: int = const 5;
four: int = const 4;
twenty: int = const 20;
cond: bool = eq x five;
br cond .if .else_if_check;

.if:
res: int = mul four x;
jmp .end;

.else_if_check:
cond: bool = eq x four;
br cond .else_if .else;
jmp .end;

.else_if:
res: int = mul five x;
jmp .end;

.else:
res: int = id twenty;
jmp .end;

.end:
print res;
ret res;
}
20 changes: 20 additions & 0 deletions tests/passing/peggy_comparison/dead_loop_deletion.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@main(): int {
j: int = const 3;
i: int = const 0;
forty: int = const 40;
one: int = const 1;

.loop_test:
cond: bool = lt i forty;
br cond .loop_body .loop_end;

.loop_body:
j: int = add j one;
i: int = add i one;
jmp .loop_test;

.loop_end:
j: int = const 2;

ret j;
}
12 changes: 12 additions & 0 deletions tests/passing/peggy_comparison/if_true.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@main(x: int): int {
cond: bool = const true;
br cond .thn .els;

.thn:
ret x;

.els:
one: int = const 1;
res: int = sub x one;
ret res;
}
17 changes: 17 additions & 0 deletions tests/passing/peggy_comparison/infinite_loop.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@main: int {
five: int = const 5;
one: int = const 1;
j: int = const 0;
i: int = id five;

.loop_test:
cond: bool = eq i five;
br cond .loop_body .loop_end;

.loop_body:
j: int = add one j;
jmp .loop_test;

.loop_end:
ret j;
}
19 changes: 19 additions & 0 deletions tests/passing/peggy_comparison/loop_based_code_motion.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@main: int {
x: int = const 0;
three: int = const 3;

.loop_test:
cond: bool = lt x three;
br cond .loop_body .loop_end;

.loop_body:
one: int = const 1;
x: int = add x one;
jmp .loop_test;

.loop_end:
five: int = const 5;
x: int = mul x five;

ret x;
}
25 changes: 25 additions & 0 deletions tests/passing/peggy_comparison/loop_invariant_code_motion.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@main(n: int, m: int) {
i: int = const 0;
twenty: int = const 20;
one: int = const 1;

.loop_test:
cond: bool = lt i twenty;
br cond .loop_body .loop_end;

.loop_body:
j: int = mul n twenty;
if_cond: bool = lt j m;
br if_cond .thn .end_if;

.thn:
j: int = add j one;

.end_if:
output: int = mul i j;
print output;
i: int = add i one;
jmp .loop_test;

.loop_end:
}
18 changes: 18 additions & 0 deletions tests/passing/peggy_comparison/loop_peeling.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@main(n: int): int {
x: int = const 0;
i: int = const 0;

.loop_test:
cond: bool = lt i n;
br cond .loop_body .loop_end;

.loop_body:
five: int = const 5;
one: int = const 1;
x: int = add x five;
i: int = add i one;
jmp .loop_test;

.loop_end:
ret x;
}
21 changes: 21 additions & 0 deletions tests/passing/peggy_comparison/loop_strength_reduction.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@main {
i: int = const 0;
d: int = const 0;
three_hundred: int = const 300;
five: int = const 5;
one: int = const 1;

.loop_test:
cond: bool = lt d three_hundred;
br cond .loop_body .loop_end;

.loop_body:
out: int = mul i five;
print out;

i: int = add i one;
d: int = add d one;
jmp .loop_test;

.loop_end:
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@main {
i: int = const 0;
d: int = const 0;
three_hundred: int = const 300;
three: int = const 3;
five: int = const 5;
one: int = const 1;
one_hundred_fifty: int = const 150;

.loop_test:
cond: bool = lt d three_hundred;
br cond .loop_body .loop_end;

.loop_body:
out: int = mul i five;
print out;

i: int = add i one;
if_cond: bool = eq d one_hundred_fifty;
br if_cond .if_then .end_if;

.if_then:
i: int = add i three;

.end_if:
d: int = add d one;

jmp .loop_test;

.loop_end:
}
15 changes: 15 additions & 0 deletions tests/passing/peggy_comparison/loop_unroll.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@main: int {
i: int = const 0;
one: int = const 1;

.loop_test:
cond: bool = lt i one;
br cond .loop_body .loop_end;

.loop_body:
i: int = add one i;
jmp .loop_test;

.loop_end:
ret i;
}
28 changes: 28 additions & 0 deletions tests/passing/peggy_comparison/simple_loop_unswitch.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ARGS: 40
@main(n: int): int {
one: int = const 1;
zero: int = const 0;
i: int = id zero;
j: int = id zero;

.loop_test:
cond: bool = lt i n;
br cond .loop_body .loop_end;

.loop_body:
print i;

cond: bool = lt n zero;
br cond .thn .ifend;

.thn:
j: int = const 2;

.ifend:
j: int = add one j;
i: int = add one i;
jmp .loop_test;

.loop_end:
ret j;
}

0 comments on commit 1a952ad

Please sign in to comment.