Patent ID: 8291398

Claim:
A compiling method executed by a processor for optimizing a program by use of a computer, the method comprising the steps of: analyzing, for an instruction to assign a value to a variable in the program, a range of the value being assignable to the variable by the instruction, as a subrange of the variable if the instruction is executed; determining, on the basis of the analyzed subrange of the variable, if the execution result of the program changes with an assignment, by the instruction, replacing, under the condition that the determination made by the determination unit is true, the instruction to assign a value to the variable with an instruction to assign a constant value in the subrange of the variable to the variable; providing a storage unit for storing the program therein, wherein the analyzing comprises accessing the storage unit and scanning the program, the subrange of the variable, and further analyzes, for each instruction referencing the variable in the program, a subrange of the variable in a case where the instruction is executed, the determining comprises determining if a subrange of the variable for a certain instruction to assign a value to the variable: is included in a subrange of the variable for a certain instruction that branches on the basis of the assigned value of the variable; and does not overlap with any subrange of the variable respectively for the other instructions each referencing to the variable, and, under the condition that the determination made by the determination unit is true, the replacing comprises changing the program by accessing the storage unit and then replacing the instruction to assign a value to the variable with an instruction to assign, to the variable, a constant value selected from the subrange of the variable for the instruction to assign the value to the variable.