The apparatus according to the present invention adds a sequence of
instructions for recording a maximum of two sets of values assigned to
variables in the procedure under the first execution and whose appearance
frequencies can reach 50% or more and their appearance frequencies to the
intermediate data of a source program to obtain primary profile
information after the end of a first execution. Further it adds another
sequence of instructions for recording the appearance frequencies of the
values of the primary profile information and the execution frequency of
the procedure to the intermediate data to obtain final profile
information after the end of a second execution. Then, it calculates a
value whose appearance frequency with respect to a variable is 50% or
more on the basis of the final profile information to optimize the
procedure regarding this value and thereby generate an object program.