Skip to content

Commit

Permalink
Merge pull request #302 from 2b3o4o/dead-branch
Browse files Browse the repository at this point in the history
add dead-branch benchmark
  • Loading branch information
sampsyo authored Oct 25, 2023
2 parents 12900cf + 7879e8b commit daaff28
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions benchmarks/long/dead-branch.bril
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@main {
v1: int = const 1;
v2: int = const 0;
counter: int = const 0;

.loop_start:
v7: int = id counter;
v8: int = const 99;
v9: bool = lt v7 v8;
br v9 .loop_body .loop_end;

.loop_body:
v3: bool = eq v1 v2; # Always false
br v3 .then .else; # .then is a dead branch - this br instruction can be optimized out by a smart compiler

.then:
v4: int = const 100;
print v4;

.else:
v4: int = const 50;

v10: int = id counter;
v11: int = const 1;
v12: int = add v10 v11;
counter: int = id v12;

jmp .loop_start;

.loop_end:
print v4;
}
1 change: 1 addition & 0 deletions benchmarks/long/dead-branch.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
50
1 change: 1 addition & 0 deletions benchmarks/long/dead-branch.prof
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
total_dyn_inst: 1196
1 change: 1 addition & 0 deletions docs/tools/bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The current benchmarks are:
* `cordic`: Print an approximation of sine(radians) using 8 iterations of the [CORDIC algorithm](https://en.wikipedia.org/wiki/CORDIC).
* `csrmv`: Multiply a sparse matrix in the [Compressed Sparse Row (CSR)][csr] format with a dense vector. The matrix and input vector are generated using a [Linear Feedback Shift Register](https://en.wikipedia.org/wiki/Linear-feedback_shift_register) random number generator.
* `digial-root`: Computes the digital root of the input number.
* `dead-branch`: Repeatedly call a br instruction whose condition always evaluates to false. The dead branch should be pruned by a smart compiler.
* `dot-product`: Computes the dot product of two vectors.
* `eight-queens`: Counts the number of solutions for *n* queens problem, a generalization of [Eight queens puzzle][eight_queens].
* `euclid`: Calculates the greatest common divisor between two large numbers using the [Euclidean Algorithm][euclid] with a helper function for the modulo operator.
Expand Down

0 comments on commit daaff28

Please sign in to comment.