I will defer to Rick Arellanes (who has already replied) on this (and most
performance questions).  HOWEVER,  I do want to re-iterate that *if*
performance is of concern to you, the best "general rule" is to compile with
  TRUNC(OPT)
and use
   COMP-5
for specific fields that MAY have values larger than their PICTURE clause
allows.

As to the "why" does IBM produce the code that it does for TRUNC(BIN) - when
this is "by definition" non-Standard conforming, this is an "old argument".
Although there have been some performance enhancements over the years
(particularly in the early years) for TRUNC(BIN), IBM does make some "odd"
choices for an environment that should not be bothered by the PICTURE
clause.

In the '02 COBOL Standard, there were a number of "true binary" data USAGEs
introduced and there are existing SHARE requirements asking for IBM to
include support for them.  When/If IBM does ever support these,  one can
only hope that they would be introduced in a performance-sensitive manner.

"Farley, Peter x23353" <peter.far...@broadridge.com> wrote in message
news:<053f2631ec9c584883847c8b4970a22803ce6...@josqems1.jsq.bsg.ad.adp.com>.
..
> 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 lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
> Search the archives at http://bama.ua.edu/archives/ibm-main.html

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

Reply via email to