1. A method of optimizing intermediate representation (IR) code comprising a thread loop, the method comprising: performing data-flow analysis on the IR code to compute variables that need to be loaded at the beginning of thread loops and stored on exit from thread loops; and according to the data-flow analysis, updating the IR code to remove load operations and store operations, wherein the updated IR code is compiled and executed on a central processing unit (CPU), and wherein the CPU is not a graphics processing unit (GPU).