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
This message and any attachments are intended only for the use of the addressee 
and
may contain information that is privileged and confidential. If the reader of 
the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.


----------------------------------------------------------------------
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