Abstract:
Method, program and system for code optimization. A sign assignment instruction with identically sized packed decimal format input and output operands is detected where the sign assignment instruction assigns a value of zero to a packed decimal data value input operand having a value of negative zero. If the input operand to the sign assignment instruction does not result from an add or subtract operation, or the value of the input operand is not greater than a value prior to that operation, the possibility that the value of the input operand of the sign assignment instruction is negative zero is checked when the input operand and the output operand have identical addresses. An instruction is generated and inserted for executing the sign assignment instruction only when there is the possibility that the operand value is negative zero.

Description:
BACKGROUND OF THE INVENTION 
       [0001]    1. Field of the Invention 
         [0002]    The present invention is related to a technique for optimizing a program, more particularly such as a COBOL program, that includes packed decimal variables. 
         [0003]    2. Description of the Related Art 
         [0004]    COBOL is a computer programming language developed in 1959 primarily for business use. It is still used today in mainframe computer systems and the like, partly to inherit past programming resources. One mainframe in computer systems is the System z, available by International Business Machines Corporation (registered trademark). 
         [0005]    In COBOL, calculations of the type are internally performed in packed decimal, unless the types of calculations used are all designated explicitly as the binary type. 
         [0006]    In a calculation that uses packed decimal, a sign can not be assigned correctly. For example, when the following calculations are made for four-digit variables, the resulting signs are incorrect. 
         [0000]    −9999− 1=&gt;−0
 
−1/10=&gt;−0
 
−5000*2=&gt;−0
 
         [0007]    The above values should be +0. When −0 is displayed as it is, it will give a strange feeling to the operator. Therefore, an instruction for correctly assigning a sign (positive or negative) is generated. Such an instruction will be referred to as a “ZAP”. 
         [0008]    A specific example of assembler code is as follows. For the expression “compute idx=idx− 1” in COBOL, in which the variable idx is defined as “01 idx pic s9(4)”, the following code is generated. 
         [0000]    1. PACK 272(3,13),24(4,8) tmp=PACK(idx)
 
2. SP 272(3,13),52(1,10) tmp=tmp− 1
 
3. NI 272(13),X ‘0F’ Set the fifth digit to 0
 
4. ZAP 272(3,13),272(3,13) tmp=ZAP(tmp)
 
5. UNPK 24(4,8),272(3,13) idx=UNPK(tmp)
 
         [0009]    Assuming that the initial value of idx is −9999, the result of the calculation in 2 above is −10000. The variable idx is a four-digit number, −10000 is rounded in 3 above to −0000. The sign of this value is incorrect. Thus, with the ZAP instruction in 4 above, −0000 is changed to +0000. 
         [0010]    The ZAP is very costly, leading to a decrease in speed. There is a demand for improving this problem. The following conventional techniques can be applicable to the optimization of COBOL and other programs. 
         [0011]    A technique is described in Japanese Unexamined Patent Publication No. 2008-102740 as follows. In a language processing system which is executed by a processor in a computer system, in branch processing, as to a branch in which two references are first compared to determine whether they are identical. If the result is true, then a branch is made, otherwise a method for verifying equivalence of instances directed by the individual references is called, and a branch is made if the return value is true. This branch, according to the comparison between the references and its result, is removed on the condition that the probability of the result of the comparison between the references being true is sufficiently small and that the removal of the branch according to the comparison between the references and its result will hardly change the result of execution of the program. 
         [0012]    A technique is described in Japanese Unexamined Patent Publication No. 2009-134523 as follows. In an assembler device 1 for converting an assembler source program to a machine language program executable by a processor 5, an extended macro instruction (Xld instruction and Xjnz instruction) included in the assembler source program is expanded to a basic instruction (Id instruction and jnz instruction) and an extended instruction (ext instruction). Thereafter, the expanded ext instruction is optimized by determining the numerical data of the operand and omitting a redundant instruction. If this optimization of the ext instruction has caused a change of the address of the label, the ext instruction is optimized again. 
         [0013]    As described in Japanese Unexamined Patent Publication No. 2005-107816 an optimization compiler optimizes a load instruction for reading data from a memory in a target program to be optimized. The optimization compiler includes: partial redundancy removal means for performing, on load instructions for reading data from the memory to variables, a process of removing partial redundancy which does not cause spill processing when the variables are allocated to a register; reverse direction register detection means for detecting a free register, which is not allocated to any variable, in an execution route arriving at the load instructions by tracking the execution sequence reversely from the instructions that use the data read by the load instructions; and free register allocating means for allocating the free register detected by the reverse direction register detection means to the read destination variables onto which the load instructions read data. 
         [0014]    As described in Japanese Unexamined Patent Publication No. 2000-81983 in order to eliminate redundant array range check, the following units are provided: a unit for eliminating redundant array range check by versioning for loop; a unit for optimizing the array range check by performing data flow analysis in the reverse order of execution; and a unit for collecting information about the array range checks already processed, by performing data flow analysis in the order of execution, and eliminating the redundant array range check on the basis of the collected information. 
         [0015]    None of the above-described conventional techniques discloses nor suggests a technique for optimizing the use of a sign assignment instruction, like a ZAP, for correctly assigning a packed decimal sign. 
       SUMMARY OF THE INVENTION 
       [0016]    An aspect of the present invention provides a method that includes detecting a sign assignment instruction that has an input operand and an output operand identical in size to each other where the sign assignment instruction operates on an input operand having a packed decimal format and assigns a value of zero to a packed decimal data value of the input operand having a value of negative zero. The method further analyzes, based on the detecting, the input operand of the sign assignment instruction to determine whether a value of the input operand results from an add or subtract operation and whether the value is greater than the value prior to the operation. The method further includes, based on the analyzing determining at least one of one of that the value of the input operand does not result from an add or subtract operation or that the value is not greater than the value prior to the operation, checking, based on the input operand and the output operand of the sign assignment instruction having identical addresses, a possibility that the value of the input operand of the sign assignment instruction is negative zero, and generating and inserting an instruction for executing the sign assignment instruction only when there is the possibility that the value is negative zero. 
         [0017]    Another aspect of the present invention provides a computer readable non-transitory article of manufacture tangibly embodying computer readable instruction which, when executed cause a computer to detect a sign assignment instruction that has an input operand and an output operand identical in size to each other, where the sign assignment instruction operates on an input operand having a packed decimal format and assigns a value of zero to a packed decimal data value of the input operand having a value of negative zero. Based on detecting the sign assignment instruction, the input operand of the sign assignment instruction is analyzed to determine whether a value of the input operand results from an add or subtraction operation and whether the value is greater than the value prior to the operation. Based on determining at least one of one of that the value of the input operand does not result from an add or subtract operation or that the value is not greater than the value prior to the operation, a possibility that the value of the input operand of the sign assignment instruction is negative zero is checked check, based on the input operand and the output operand of the sign assignment instruction having identical addresses, and an instruction for executing the sign assignment instruction is generated and inserted only when there is the possibility that the value is negative zero. 
         [0018]    Another aspect of the present invention provides a computer system for optimizing a sign assignment instruction for correctly assigning a packed decimal sign. The system includes a memory, a processor communicatively coupled to the memory and an optimization module communicatively coupled to the memory and the processor. The optimization module, when operating, detects a sign assignment instruction having an input operand and an output operand identical in size to each other. The sign assignment instruction operates on an input operand having a packed decimal format and assigns a value of zero to a packed decimal data value of the input operand having a value of negative zero. The optimization module, when operating, further analyzes, based on detecting the sign assignment instruction, the input operand of the sign assignment instruction to determine whether a value of the input operand results from an add or subtraction operation and whether the value is greater than the value prior to the operation. The optimization module, when operating, further, based on a determination of at least one of one of that the value of the input operand does not result from an add or subtract operation and that the value is not greater than the value prior to the operation, checks, based on the input operand and the output operand of the sign assignment instruction having identical addresses, a possibility that the value of the input operand of the sign assignment instruction is negative zero, and generates and inserts an instruction for executing the sign assignment instruction only when there is the possibility that the value is negative zero. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0019]    Embodiments of the present invention will be described in reference to the drawings. It should be understood that the embodiments are intended to describe preferred modes of the present invention, and there is no intention to limit the scope of the present invention to the content described below. Unless otherwise specified, like reference numerals denote like parts in the drawings. 
           [0020]      FIG. 1  is a block diagram showing the hardware configuration for carrying out the present invention. 
           [0021]      FIG. 2  is a block diagram showing the functional configuration of a first embodiment of the present invention. 
           [0022]      FIG. 3  is a block diagram showing the functional configuration of a second embodiment of the present invention. 
           [0023]      FIG. 4  is a block diagram showing the functional configuration of a third embodiment of the present invention. 
           [0024]      FIG. 5  is a block diagram showing the functional configuration of an optimization module according to a further embodiment of the present invention. 
           [0025]      FIG. 6  is a flowchart illustrating the process of a processing routine according to a further embodiment of the present invention. 
           [0026]      FIG. 7  is a flowchart illustrating the process of a detection routine according to a further embodiment of the present invention. 
           [0027]      FIG. 8  is a flowchart illustrating the process of an analysis routine according to a further embodiment of the present invention. 
           [0028]      FIG. 9  is a flowchart illustrating the process of a removal routine according to a further embodiment of the present invention. 
           [0029]      FIG. 10  is a flowchart illustrating the process of a reduction routine according to a further embodiment of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS 
       [0030]    An object of the present invention is to provide a technique of optimizing the use of a sign assignment instruction for correctly assigning a packed decimal sign. 
         [0031]    Another object of the present invention is to provide a technique of optimizing the operating speed of a program by efficiently removing a costly sign assignment instruction for correctly assigning a packed decimal sign. 
         [0032]    The present invention has been accomplished in view of the foregoing problems. According to the present invention, for a sign assignment instruction to correctly assigning a packed decimal sign, for example a ZAP instruction, when the input and output fields of the instruction are identical in size to each other, the optimization is carried out. 
       ZAP Instruction Removal Processing: 
       [0033]    (1-1) Processing of removing a ZAP instruction or replacing it with a copy instruction when it can be determined that an input value of the ZAP instruction is not −0 at all times. This processing is performed when it can be determined that the input value results from an add operation or a subtraction operation and the value is greater than the value prior to the operation (for example, the operation of adding 1). 
         [0034]    (1-2) Remove the ZAP instruction when the input and output addresses are also identical to each other. 
         [0035]    (1-3) Replace the ZAP instruction with the instruction for copying the input to the output when it can be determined that the input and output addresses are different from each other and not overlapping each other. 
       ZAP Instruction Strength Reduction Processing: 
       [0036]    (2-1) Processing of generating a code so as to generate an instruction for checking, in bit representation, the possibility that an input value of a ZAP instruction is −0, and skip the ZAP instruction or execute a copy instruction when there is no possibility that the input value is −0. The checking of the possibility of the input value being −0 is made rapidly by performing an AND between a sign part and 9 by creating a mask value corresponding to the number of digits. 
         [0037]    (2-2) Refrain from executing the ZAP instruction when the input and output addresses are also identical to each other. 
         [0038]    (2-3) Execute the instruction for copying the input to the output, rather than the ZAP instruction, when it can be determined that the input and output addresses are different from each other and not overlapping each other. 
         [0039]    The removal technique including the above-described processes (1-1), (1-2), and (1-3) and the reduction technique comprising the above-described processes (2-1), (2-2), and (2-3) can be performed independently from each other, or can be applied together. Further, the reduction technique can be applied first, which can be followed by the removal technique. 
         [0040]    In a first aspect of the present invention, the above-described function is implemented as a conversion tool for a compiled COBOL binary execution program. 
         [0041]    In a second aspect of the present invention, the above-described function is implemented as an optimization function of a COBOL compiler. 
         [0042]    According to the present invention, in a program using sign assignment instructions for correctly assigning packed decimal signs, such a sign assignment instruction is removed or the generation thereof is suppressed within a range ensuring a proper operation. This improves the operating speed of the resultant code. 
         [0043]    Referring to  FIG. 1 , a block diagram of the computer hardware for implementing the system configuration and processing according to an embodiment of the present invention is shown. This computer hardware preferably has the configuration conforming to the IBM (registered trademark) System z (registered trademark) architecture. 
         [0044]    Referring to  FIG. 1 , a CPU  104 , a main storage (a RAM)  106 , a hard disk drive (HDD)  108 , a keyboard  110 , a mouse  112 , and a display  114  are connected to a system bus  102 . The CPU  104  is preferably a z10 (trademark) processor chip. The main storage  106  is preferably one having a memory capacity of 16 GB or more. The hard disk drive  108  can be one having a memory capacity of 1 TB or more. 
         [0045]    Although not individually illustrated, the hard disk drive  108  has an operating system stored therein in advance. The operating system is z/OS, can be any one of z/VM, z/VSE, and other operating systems that is compatible with the computer hardware being used. 
         [0046]    The keyboard  110  and the mouse  112  are used to operate a program which has been loaded from the hard disk drive  108  to the main storage  106  and displayed on the display  114  by the function of the operating system, and to type characters. 
         [0047]    The display  114  is preferably a liquid crystal display. A liquid crystal display having an arbitrary resolution, such as XGA (with a resolution of 1024×768) or UXGA (with a resolution of 1600×1200) can be used. Although not illustrated, the display  114  is used for displaying numerical values, such as accounting data, calculated by a COBOL program. 
         [0048]    In a first embodiment of the present invention, as shown in  FIG. 2 , the hard disk drive  108  stores a COBOL source code  202  and a compiler  204  in which a ZAP instruction removing/reducing function according to the present invention has been installed. In this case, in response to an operator&#39;s operation, an optimized COBOL binary executable file  206 , with the ZAP instructions removed or reduced as appropriate, is generated directly from the COBOL source code  202  by the compiler  204 . The resultant optimized COBOL binary executable file  206  is stored in the hard disk drive  108 . Thus, a code optimization function according to the present invention that is included in the compiler  204  is called when the compiler  204  generates a binary code. The first embodiment is effective when the COBOL source code  202  is in existence. 
         [0049]    In a further embodiment of the present invention, referring to  FIG. 3 , the hard disk drive  108  stores a COBOL binary executable file  302  that has not been optimized in the sense of the present invention, and an optimization module  304  In this case, in response to an operator&#39;s operation, the COBOL binary executable file  302  is converted into an optimized COBOL binary executable file  306  by the conversion module  304  which executes the ZAP instruction removing/reducing function according to the present invention. The second embodiment is effective when there is no source code and only a binary executable file is available because of a legacy program or for other reasons. 
         [0050]    In a further embodiment of the present invention, referring to  FIG. 4 , the hard disk drive  108  stores a COBOL source code  202 , a compiler  402  in which the optimization function according to the present invention has not been installed, and an optimization module  304  which is identical to that in  FIG. 3 . In this case, in response to an operator&#39;s operation, the COBOL source code  202  is temporarily converted, by the compiler  402 , into a COBOL binary executable file  404  that has not been optimized. Then, the COBOL binary executable file  404  is converted into an optimized COBOL binary executable file  406  by the conversion module  304 . This embodiment is effective when a source code and an existing COBOL compiler are both available. 
         [0051]    The functions of the optimization module  304  will now be described in reference to the functional block diagram in  FIG. 5 . The compiler  204  in  FIG. 2  has installed the optimization function equivalent to that of the optimization module  304 . Therefore, the following description of the functions of the optimization module  304  also describes the code optimization function of the present invention that is included in the compiler  204 . 
         [0052]    Referring to  FIG. 5 , the optimization module  304  includes a processing routine  502 , an input routine  504 , a detection routine  506 , an analysis routine  508 , a removal routine  510 , a reduction routine  512 , and an output routine  514 . The processing routine  502  integrates all the functions of the optimization module  304 . The processing routine  502  calls as appropriate the input routine  504 , the detection routine  506 , the analysis routine  508 , the removal routine  510 , the reduction routine  512 , and the output routine  514  for processing. The function of the processing routine  502  will be described in reference to the flowchart in  FIG. 6 . 
         [0053]    The input routine  504  has the function of reading the unoptimized COBOL binary executable file  302  stored in the hard disk drive  108 . 
         [0054]    The detection routine  506  has the function of detecting the position of a ZAP as a candidate for removal in the COBOL binary executable file  302 . The function of the detection routine  506  will be described in reference to the flowchart in  FIG. 7 . 
         [0055]    The analysis routine  508  is called during the detection routine  506  to analyze the definitions for an input of a ZAP. The function of the analysis routine  508  will be described in reference to the flowchart in  FIG. 8 . 
         [0056]    The removal routine  510  is called during the detection routine  506  to execute the function of removing a ZAP instruction. The function of the removal routine  510  will be described in reference to the flowchart in  FIG. 9 . 
         [0057]    The reduction routine  512  is called during the detection routine  506  to execute ZAP instruction strength reduction processing. The function of the reduction routine  512  will be described in reference to the flowchart in  FIG. 10 . 
         [0058]    The output routine  514  writes a result of the processing routine  502 , as the optimized COBOL binary executable file  306 , onto the hard disk drive  108 . 
         [0059]    The programs for the processing routine  502 , the input routine  504 , the detection routine  506 , the analysis routine  508 , the removal routine  510 , the reduction routine  512 , and the output routine  514  can be written in an arbitrary programming language, such as PL/I, assembler, or REXX, that is compatible with the operating system. 
         [0060]    The processes in the routines of the optimization module  304  will be described in reference to the flowcharts in  FIGS. 6 to 10 . 
         [0061]      FIG. 6  is a flowchart illustrating the processing routine  502  for optimization of the instructions for correctly assigning packed decimal signs. Steps  602  to  606  in  FIG. 6  all the ZAP instructions for correctly assigning signs in an optimization target area are performed. 
         [0062]    In step  604  in the loop, the processing routine  502  calls the detection routine  506 , shown in the flowchart in  FIG. 7  which will be described below, to execute “removal processing for a sign assignment instruction” for the ZAP instructions. 
         [0063]    Once all the ZAP instructions have been checked, the process exits step  606  and is terminated. Although not illustrated in  FIG. 6 , the processing routine  502  outputs an optimized code as a result of the conversion, by the output routine  514 . 
         [0064]      FIG. 7  is a flowchart illustrating the process of the detection routine  506  which is called in step  604  to execute the removal processing for a sign assignment instruction. 
         [0065]    Referring to  FIG. 7 , in step  702 , the detection routine  506  determines whether the input and output sizes of the ZAP are identical to each other. If the sizes are different from each other, the process is terminated without doing anything. 
         [0066]    If the detection routine  506  determines in step  702  that the input and output sizes of the ZAP are identical to each other, in step  704 , the detection routine  506  calls AnalyzeDEF(I), which is the analysis routine  508 , to check whether sign assignment is necessary for each definition I for the input of the ZAP. The process of the analysis routine  508  will be described in detail later with reference to the flowchart in  FIG. 8 . 
         [0067]    The analysis routine  508  returns an analysis result which shows whether the sign assignment is necessary or not. Based on the analysis result, the detection routine  506  determines in step  706  whether the sign assignment is unnecessary for all the definitions. 
         [0068]    If the detection routine  506  determines in step  706  that the sign assignment is unnecessary for all the definitions, in step  708 , the detection routine  506  calls the removal routine  510  which performs ZAP removal processing, and the process is terminated. The removal routine  510  will be described in detail later in reference to the flowchart in  FIG. 9 . 
         [0069]    If the detection routine  506  determines in step  706  that the sign assignment can be necessary for some definitions. In step  710 , the detection routine  506  calls the reduction routine  512  which performs ZAP instruction strength reduction processing, and the process is terminated. The reduction routine  512  will be described in detail later in reference to the flowchart in  FIG. 10 . 
         [0070]      FIG. 8  is a flowchart of the analysis routine  508 , i.e. AnalyzeDEF(I), where I is for example the following expression, which is shown as I1 below. 
         [0000]      001 COMPUTE INPUT=INPUT+1  (I1)
 
         [0000]      002 . . . =ZAP(INPUT) 
         [0071]    In a more complex example as follows, the definitions for the input of the ZAP (INPUT) below are I1 and I2. 
         [0000]    
       
         
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 001 IF ... THEN 
               
               
                   
                 002 COMPUTE INPUT = INPUT + 1 --- (I1) 
               
               
                   
                 003 ELSE 
               
               
                   
                 004 COMPUTE INPUT = INPUT * 2 --- (I2) 
               
               
                   
                 005 END-IF. 
               
               
                   
                 006 ... = ZAP(INPUT) 
               
               
                   
                   
               
             
          
         
       
     
         [0072]    The analysis routine  508  determines in step  802  whether the sign for I is already correct. If so, in step  804 , the analysis routine  508  returns the determination that the sign assignment is unnecessary. 
         [0073]    If the analysis routine  508  cannot determine that the sign for I is already correct, in step  806 , the analysis routine  508  determines whether I is an add instruction. If so, in step  808 , the analysis routine  508  determines whether one of the operands for calculating I is 0 or greater. If so, the analysis routine  508  returns in step  810  and determines that the sign assignment is unnecessary. Otherwise, the analysis routine  508  returns in step  812  the determination that the sign assignment is necessary. 
         [0074]    If the analysis routine  508  determines in step  806  that I is not an add instruction, in step  814 , the analysis routine  508  determines whether I is a subtraction instruction. If so, in step  816 , the analysis routine  508  determines whether either the condition that the first operand for calculating I is 0 or greater or the condition that the second operand for calculating I is 0 or smaller is met. If so, the analysis routine  508  returns in step  818  the determination that the sign assignment is unnecessary. Otherwise, the analysis routine  508  returns to step  820  that determines that the sign assignment is necessary. 
         [0075]    If the analysis routine  508  determines in step  814  that I is not a subtraction instruction, in step  822 , the analysis routine  508  determines whether it can be determined that the sign assignment is unnecessary for the output of I when it is determined that the sign assignment is unnecessary for the input of I. This determination can be made from the expression for calculating I. If not in step  822 , the analysis routine  508  returns in step  820  the determination that the sign assignment is necessary. 
         [0076]    If the analysis routine  508  determines in step  822  that the sign assignment is unnecessary for the input of I, it can be determined that the sign assignment is unnecessary for the output as well. In step  824 , the analysis routine  508  checks whether sign assignment is necessary for each definition J for the input of I, by calling AnalyzeDEF(J) recursively. 
         [0077]    If the analysis routine  508  determines in step  826  that the sign assignment is unnecessary for all the definitions J, the analysis routine  508  returns in step  830  the determination that the sign assignment is unnecessary. Otherwise, the analysis routine  508  returns in step  828  the determination that the sign assignment is necessary. 
         [0078]      FIG. 9  is a flowchart illustrating the process of the removal routine  510 . Referring to  FIG. 9 , in step  902 , the removal routine  510  determines whether the input and output addresses of the ZAP are exactly identical to each other. If so, the removal routine  510  removes the ZAP in step  904 , and the process is terminated. 
         [0079]    If the removal routine  510  determines in step  902  that the input and output addresses of the ZAP are not exactly the same then in step  906 , the removal routine  510  determines whether it is probable that the input and output addresses of the ZAP overlap each other. If so, the process is terminated without doing anything. The technique of determining whether two memory accesses are overlapping each other is conventionally known. When a memory access is represented as a combination of base address, index, offset, and length, if the input and output are identical in base address and index, the determination as to whether the input and output addresses are overlapping each other can be made on the basis of the offsets and lengths. If the input and output have base addresses and indices different from each other, the analysis is often unachievable, in which case it is necessary to assume that the addresses are overlapping each other. In the alias analysis or the like, there are some cases where it can be determined that the input and output addresses are not overlapping each other. 
         [0080]    If the removal routine  510  determines in step  906  that there is no possibility that the input and output addresses of the ZAP overlap each other, in step  908 , the removal routine  510  generates an instruction for copying the input to the output, instead of the ZAP, and the process is terminated. 
         [0081]      FIG. 10  is a flowchart illustrating the process of the reduction routine  512 . Referring to  FIG. 10 , in step  1002 , the reduction routine  512  determines whether the input and output addresses of the ZAP are exactly identical to each other. If so, in step  1004 , the reduction routine  512  generates an instruction for checking whether the input of the ZAP is −0, and generates an instruction for executing the ZAP only when the input is −0. The process is then terminated. It is noted that the checking of whether the input of the ZAP is −0 is implemented by an instruction for performing an AND between the sign part and 9 by creating a mask value corresponding to the number of digits. This process will be described in detail later in a supplemental description on packed decimal. 
         [0082]    If the reduction routine  512  determines in step  1002  that the input and output addresses of the ZAP are not exactly the same, in step  1006 , the reduction routine  512  determines whether it is probable that the input and output addresses of the ZAP overlap each other. If so, the process is terminated. The technique of determining whether two memory accesses are overlapping each other can be the same as the one described above in conjunction with step  906 . 
         [0083]    If the reduction routine  512  determines in step  1006  that there is no possibility that the input and output addresses of the ZAP overlap each other then in step  1008 , the reduction routine  512  generates an instruction for checking whether the input of the ZAP is −0, and generates an instruction for copying the input to the output if the input is not −0 and executing the ZAP if the input is −0. The process is then terminated. 
         [0084]    A supplemental description will now be made on packed decimal. In packed decimal, the sign part is defined in numerical values as follows: 
         [0000]    Positive sign: 12 (preferred), 10, 14, 15
 
Negative sign: 13 (preferred), 11
 
         [0085]    The negative sign is 1101 or 1011 in bit representation. In order to rapidly find that the sign part is neither of these values, a code shown by a pseudocode as follows is generated for a ZAP instruction. 
         [0000]    
       
         
               
             
           
               
                   
               
             
             
               
                 tmpReg = F9, FFF9, FFFFF9, or FFFFFFF9, depending on the size of a 
               
               
                 decimal value (for one byte, two bytes, three bytes, and four or more 
               
               
                 bytes, respectively) tmpReg &amp;= * (the rightmost address of the 
               
               
                 decimal value − 3) 
               
               
                 if (tmpReg == 9 &amp;&amp; 
               
               
                  ((the rightmost byte value of the decimal value &amp; 6) != 2 and ((the 
               
               
                 rightmost byte value of the decimal value &amp; 6) != 4){ 
               
               
                  // Use a TM instruction in System z 
               
               
                 &lt;Do ZAP&gt; 
               
               
                 } 
               
               
                   
               
             
          
         
       
     
         [0086]    If an instruction for System z is used, the following machine code is generated corresponding to the above-described pseudocode. 
         [0000]    
       
         
               
               
               
             
               
               
               
             
               
               
               
             
               
               
               
             
               
               
             
               
             
           
               
                   
               
             
             
               
                 IILF 
                 GPR0,0xFFFFF9 
                   
               
               
                 N 
                 GPR0,320(GPR2) 
                 // Perform an AND with variable 
               
               
                 CHI 
                 GPR0,9 
                 // Is the result 9? 
               
             
          
           
               
                 BRC 
                 BNERC(0x6), Label SKIP 
                 // Skip if it is not 9 
               
             
          
           
               
                 TM 
                 323(GPR2), 0x06 
                 // If it is 10 or 01 in bit representation, 
               
               
                   
                   
                 1 is set as CC. 
               
             
          
           
               
                 BRC 
                 (0xb), Label SKIP 
                 // Skip if it is not 10 or 01 in 
               
               
                   
                   
                 bit representation 
               
             
          
           
               
                 ZAP 
                 321(3,GPR2), 321(3,GPR2) 
               
             
          
           
               
                 Label SKIP: 
               
               
                   
               
             
          
         
       
     
         [0087]    The technique of using a code described in the pseudocode as described above is advantageous in that the majority of numbers other than −0 can be excluded by checking tmpReg==9. 
         [0088]    Besides this technique, another conceivable technique is to use FF instead of F9 as a mask of the sign byte, and perform an AND and compare the result to see whether it is neither 13 or 11. With this technique, the comparison needs to be made at least twice for any number other than −0. 
         [0089]    While the 32-bit instruction was used in the above example, a 64-bit instruction can be used as well. A modified ZAP instruction can further be converted, although it will probably have a little effect on performance. Specifically, it is conceivable to change only the sign by a bit operation so as to set the sign part to 15 by using an OR instruction. This technique is only applicable to up to four byte packed decimal when a 32-bit instruction is used (or up to eight bytes with a 64-bit instruction). 
         [0090]    While the present invention has been described above about the case where COBOL code is executed in z/OS on the IBM (registered trademark) System z (registered trademark) architecture, the present invention is not restricted to the above-described case. The present invention can be performed on a computer having an arbitrary architecture, such as a personal computer. 
         [0091]    The present invention is applicable, not only to COBOL, but also to an arbitrary programming language that uses a sign assignment instruction for correctly assigning a packed decimal sign.