Hi, I'm working on loop tiling recently. I want to add this optimization to GCC. But I have encoutered some problems here and ask for help.
For the code below as an example: for (int i = 0; i < 12; i++) { for (int j = 0; j < arr.length; j++) { // arr.length may be huge // do something with arr[j] } } I want to create an outermost loop that wraps around the two loops of the inner layer, and at the same time change the loop variables of the innermost loop. The final result is as follows: for (int k = 0; k < 8192; k++) { for (int i = 0; i < 12; i++) { for (int j = 0; j < arr.length / 8192; j++) { // do something with arr[k * (arr.length / 8192) + j] } } } But I don't know how to do this properly. I'm stuck with virtual oprands and PHIs. Is there any existing optimization in GCC that I can refer to? Thanks. Hanke Zhang.