# Phase Ordering Problem - Solve by Static Analyze

Hello everyone,

I would like to solve this problem ( or make better than O3) by using static analyze the llvm IR.

My method is: Get the passes of “-O3" and reorder them by random selection. Get many of the random passes and generate the llvm IR by these passes from a single source IR.

for example:
The passes of O3: A, B, C

get the pass,

random 1 passes: A, C, B
random 2 passes: B, C, A
random 3 passes: C, A, B

apply these pass on a identical source IR and get ‘four’ files: O3.ll, random1.ll, random2.ll, random3.ll

How could I compare the performance of four of them by analyze the IR code ?

Now I’m using the fit function like this formula [1] and calculate all of the IR I generate. And then get the max fit value of them.

The one which has the max fit value is better than “-O3” but only faster about 10% or less. It is not enough for me. And the variables in the fit function I created are just selected by my experiments and I couldn’t find the paper or relative information about this issue.

I hope someone can help me to figure out or just give me a keyword to let me search and study.

thanks

[1] (the lines of vectorbody blocks - store instconut - load instcount) / (instruction cost + instruction count)