Hi All,

I like to test the register pressure of the register allocator available in LLVM. I’m able to successfully print out the steps that the register allocator takes, but I’m having a challenge creating a test example that forces the register pressure to be high(lots of spills and reloads).

I created the sample below that calculate a random matrix vector calculation. It takes in an `UNROLL_FACTOR`

based on how many times you like the loop to be unrolled. My assumption is that this would increase the register pressure, but it doesn’t seem to be spilling for any of the register allocators when I increase this value.

```
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #define AROW 32736
5 #define ACOL 32736
6 #define BCOL 32736
7
8 #ifndef UNROLL_FACTOR
9 #define UNROLL_FACTOR 0
10 #endif
11
12 void mat_vec(int** arrA, int* arrB, int* result )
13 {
14
15 for( int i = 0; i < AROW; i++ ) {
16
17 result[i] = 0;
18
19 #pragma clang loop unroll_count(UNROLL_FACTOR)
20 for( int k = 0; k < ACOL; k++ ) {
21
22 int t = arrA[i][k] * arrB[k];
23 result[i] += t;
24
25 }
26 }
27
28 };
29
30
31 int main()
32 {
33 /* declarations */
34 int** A = new int* [ACOL];
35 int* B = new int [BCOL];
36 int* result = new int [BCOL];
37
38 for( int i = 0; i < ACOL; i++ )
39 {
40 A[i] = new int[AROW];
41 }
42
43 srand(1337);
44
45 for( int i = 0; i < ACOL; i++ )
46 {
47 for( int j = 0; j < AROW; j++ )
48 {
49 A[i][j] = rand();
50 }
51 }
52
53 for( int i = 0; i < BCOL; i++)
54 B[i] = rand();
55
56
57 mat_vec( A, B, result );
58
59 for( int i = 0; i < BCOL; i++ )
60 {
61 result[i] = result[i];
62 }
63
64 /* clean up */
65 for( int i = 0; i < ACOL; i++ )
66 {
67 delete [] A[i];
68 }
70 delete [] A;
71 delete [] B;
72 delete [] result;
73 return 0;
```

I wanted to know if this or any other examples or tests I could generate could help test register pressure. Any assistance or guidance would be greatly appreciated.

Thank you.