From 61e43449dccaaa1656034ec55b0af1067128c25d Mon Sep 17 00:00:00 2001 From: Justin Ngai Date: Thu, 31 Aug 2023 15:43:36 -0400 Subject: [PATCH 1/2] Add IsDecreasing benchmark --- benchmarks/core/is-decreasing.bril | 47 ++++++++++++++++++++++++++++++ benchmarks/core/is-decreasing.out | 1 + benchmarks/core/is-decreasing.prof | 1 + docs/tools/bench.md | 1 + 4 files changed, 50 insertions(+) create mode 100644 benchmarks/core/is-decreasing.bril create mode 100644 benchmarks/core/is-decreasing.out create mode 100644 benchmarks/core/is-decreasing.prof diff --git a/benchmarks/core/is-decreasing.bril b/benchmarks/core/is-decreasing.bril new file mode 100644 index 000000000..8819f97ec --- /dev/null +++ b/benchmarks/core/is-decreasing.bril @@ -0,0 +1,47 @@ +# Input: an array of length 6 +# Output: if an number contains digits in strictly decreasing order +# ARGS: 954320 +@main(x: int) { + tmp0: bool = call @is_decreasing x; + tmp: bool = id tmp0; + print tmp; +} +@is_decreasing(x: int): bool { + tmp: int = id x; + tmp1: int = const 1; + tmp2: int = const -1; + tmp3: int = mul tmp1 tmp2; + prev: int = id tmp3; +.label4: + tmp7: int = const 0; + tmp8: bool = gt tmp tmp7; + br tmp8 .label5 .label6; +.label5: + tmp9: int = call @last_digit tmp; + digit: int = id tmp9; + tmp10: bool = lt digit prev; + br tmp10 .label11 .label12; +.label11: + tmp14: bool = const false; + ret tmp14; + jmp .label13; +.label12: + jmp .label13; +.label13: + prev: int = id digit; + tmp15: int = const 10; + tmp16: int = div tmp tmp15; + tmp: int = id tmp16; + jmp .label4; +.label6: + tmp17: bool = const true; + ret tmp17; +} +@last_digit(x: int): int { + tmp18: int = const 10; + tmp19: int = div x tmp18; + tmp20: int = const 10; + tmp21: int = mul tmp19 tmp20; + tmp22: int = sub x tmp21; + ret tmp22; +} diff --git a/benchmarks/core/is-decreasing.out b/benchmarks/core/is-decreasing.out new file mode 100644 index 000000000..27ba77dda --- /dev/null +++ b/benchmarks/core/is-decreasing.out @@ -0,0 +1 @@ +true diff --git a/benchmarks/core/is-decreasing.prof b/benchmarks/core/is-decreasing.prof new file mode 100644 index 000000000..9c486714f --- /dev/null +++ b/benchmarks/core/is-decreasing.prof @@ -0,0 +1 @@ +total_dyn_inst: 127 diff --git a/docs/tools/bench.md b/docs/tools/bench.md index bbce89d1f..6e841b399 100644 --- a/docs/tools/bench.md +++ b/docs/tools/bench.md @@ -33,6 +33,7 @@ The current benchmarks are: * `function_call`: For benchmarking the overhead of simple function calls. * `gcd`: Calculate Greatest Common Divisor (GCD) of two input positive integer using [Euclidean algorithm][euclidean_into]. * `hanoi`: Print the solution to the *n*-disk [Tower of Hanoi][hanoi] puzzle. +* `is-decreasing`: Print if a number contains strictly decreasing digits. * `loopfact`: Compute *n!* imperatively using a loop. * `mandelbrot`: Generates a really low resolution, ascii, [mandelbrot set][mandelbrot]. * `mat-inv` : Calculates the inverse of a 3x3 matrix and prints it out. From cbe55500af23a29d069d3196424588b3558757a0 Mon Sep 17 00:00:00 2001 From: Justin Ngai Date: Thu, 7 Sep 2023 15:27:28 -0400 Subject: [PATCH 2/2] Update documentation for is-decreasing benchmark --- benchmarks/core/is-decreasing.bril | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/core/is-decreasing.bril b/benchmarks/core/is-decreasing.bril index 8819f97ec..da1ba4085 100644 --- a/benchmarks/core/is-decreasing.bril +++ b/benchmarks/core/is-decreasing.bril @@ -1,4 +1,4 @@ -# Input: an array of length 6 +# Input: an integer # Output: if an number contains digits in strictly decreasing order # ARGS: 954320 @main(x: int) {