The invention discloses a method for reducing register overflow caused by fine-grained randomization safety optimization, and relates to the technical field of compiler cycle optimization. First, the variables in the registers in the cycle body are reclassified, including cycle invariants, cycle induction variables and cycle changes. After the classification, the variables in the registers in the loop body are identified; finally, according to the number of loop invariants, loop induction variables, and loop variations in the loop body registers after identification, the loop expansion factor is obtained. The present invention proposes register pressure sensitive The loop unrolling method can improve the loop optimization effect to a certain extent and reduce the occurrence of register overflow; in addition, for randomization optimization, hot code, generally the loop body is more sensitive to the performance load brought by randomization, thus improving loop unrolling Optimizations can also improve the performance of fine-grained randomization security optimizations.