Farley, Peter x23353 wrote:
I am failing to understand something about the code generation that the
Enterprise COBOL compiler (V3.4.1) performs.  For a WORKING-STORAGE
variable defined like this:

77  WORK-WORD9          PIC S9(09) BINARY.

with TRUNC(BIN) and OPTIMIZE(STD) in effect, this IF statement:

IF (WORK-WORD9 < -1) OR (WORK-WORD9 > +256)

Generates a bunch of code to convert WORK-WORD9 to packed decimal in
temporary storage (and it does it *twice* no less!) to then do
compare-packed for each of the literal values.

How or why is it that the compiler does not just use binary constants
for such a pair of comparisons?  It just does not make any sense to me
for the compiler to convert a fullword binary variable to packed in this
case, and to do it twice for goodness sake.  And secondly, if it really
*has* to do the conversion, doesn't the optimizer realize it already did
it already?

The description of OPTIMIZE(FULL) doesn't sound like it will help here,
though I will try it.  OPTIMIZE(FULL) says it eliminates unreferenced
WORKING-STORAGE but says nothing about better code optimization.

Confused,

Peter

Peter,

I can't speak with authority, since the details are hidden and,
to some degree, proprietary. But I once learned that when working
with pic s9(9) binary data, the compiler converts to packed to
avoid or intercept overflows. The simplest fix / workaround is to
declare these fields as s9(8) binary. Give that a try and see if
it works better.


Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

  z/OS Application development made easier
    * Our classes include
       + How things work
       + Programming examples with realistic applications
       + Starter / skeleton code
       + Complete working programs
       + Useful utilities and subroutines
       + Tips and techniques

==> Check out the Trainer's Friend Store to purchase z/OS  <==
==> application developer toolkits. Sample code in four    <==
==> programming languages, JCL to Assemble or compile,     <==
==> bind and test.                                         <==
==>   http://www.trainersfriend.com/TTFStore/index.html    <==

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to