Skip to content

Commit

Permalink
Merge pull request #262 from MelindaFang-code/reverse_int
Browse files Browse the repository at this point in the history
reverse_int
  • Loading branch information
sampsyo authored Aug 30, 2023
2 parents e2c821f + 1354935 commit c8a6d32
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
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 @@ -54,6 +54,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

0 comments on commit c8a6d32

Please sign in to comment.