Skip to content
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

reverse_int #262

Merged
merged 4 commits into from
Aug 30, 2023
Merged
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
30 changes: 30 additions & 0 deletions benchmarks/core/reverse.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# ARGS: 123
@main (input: int){
n: int = id input;
v0: int = const 0;
v1: int = const 10;
result: int = id v0;
v2: bool = const true;
notdone: bool = id v2;
.for.cond.3:
v4: bool = id notdone;
br v4 .for.body.3 .for.end.3;
.for.body.3:
v5: int = id n;
a: int = div v5 v1;
floor: int = mul a v1;
remainder: int = sub v5 floor;
result: int = mul result v1;
result: int = add result remainder;
n: int = id a;
comp1: bool = eq n v0;
br comp1 .if.body .for.incre;
.if.body:
notdone: bool = const false;
jmp .for.cond.3;
.for.incre:
jmp .for.cond.3;
.for.end.3:
print result;
}

1 change: 1 addition & 0 deletions benchmarks/core/reverse.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
321
1 change: 1 addition & 0 deletions benchmarks/core/reverse.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
total_dyn_inst: 46
1 change: 1 addition & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The current benchmarks are:
* `sum-divisors`: Prints the positive integer divisors of the input integer, followed by the sum of the divisors.
* `sum-sq-diff`: Output the difference between the sum of the squares of the first *n* natural numbers and the square of their sum.
* `up-arrow`: Computes [Knuth's up arrow][uparrow] notation, with the first argument being the number, the second argument being the number of Knuth's up arrows, and the third argument being the number of repeats.
* `reverse`: Compute number with reversed digits (e.g. 123 -> 321).

Credit for several of these benchmarks goes to Alexa VanHattum and Gregory Yauney, who implemented them for their [global value numbering project][gvnblog].

Expand Down