1. A method of optimizing intermediate representation (IR) code comprising a plurality of thread loops, the method performed by a computing device comprised of storage hardware and processing hardware, the method comprising: receiving the IR code and storing the IR code in the storage hardware, the IR code comprising the thread loops, wherein the thread loops were generated by replacing corresponding thread blocks during de-parallelization of original IR code comprised of the thread blocks, the thread loops of the IR code comprising temporary scalar variables and operations therewith generated and inserted into the IR code during the de-parallelization of the thread blocks of the original IR code; performing, by the processing hardware, data-flow analysis on the received IR code to identify, among the temporary scalar variables, any temporary scalar variables within thread loops and at beginnings or ends of thread loops that, according to the entirety of the IR code including the operations in the thread blocks, are temporary scalar 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, by the processing hardware, the IR code in the storage hardware, to remove load operations and store operations of the identified temporary scalar variables, wherein the updated IR code is compiled to be executed by a central processing unit (CPU).