Bernd Oppolzer wrote:

Hello mainframe C users,


That looks as if the compiler guessed that the condition
(ppli == 0xff000000u) can never be true. But because ppli is
an unsigned int, and int has size 32, of course it can (and
it does, as we can see in the case when printf is present).


The value 0xff000000 is also an unsigned int, if 'ppli' is an
unsigned int (with an indeterminant value) then the comparison
is quite valid and can't be elided.

Recall that hex constants (those beginning with 0x) are unsigned-int
by definition in the C standard.

And, certainly, when you cast a pointer to an unsigned it, the compiler
should not apply an special consideration to the definition of pointers
in 31-bit mode.  Although, you _could_ decide that a pointer can't
have its upper bit set, it's quite clear that it often does.

The IBM compiler could be misapplying range optimizations, assuming
that a 31-pointer is in the range [0x0 .. 0x7fffffff] and therefor could
never be equal to 0xff000000... but, that would be quite a stretch.
If they are doing this, I can bet your report to IBM will cause
an option to be added to quit doing it :-)

You might want to check to see if the function has been in-lined,
and if so, perhaps the parameter was a known constant or a value
of a known range... which would give the compiler the flexibility
to do what you observed.
When I compiled your example (removing the 'static' modifier)
I got this with the Dignus compiler:

* ***      if (ppli == 0xff000000u)
        C     2,@lit_217_2
        BNE   @L3

(where @lit_217_2 was your value)  and I doing the same with the
IBM compiler, I got this:

                         000021 |       *     if (ppli == 0xff000000u)
000068 5520 3052 000021 | CL r2,=F'-16777216'
00006C  4770  303E        000021 |                BNE      @1L1


which looks rather similar (both compiled with -O.)

Which version of the IBM compiler are you using?


  - Dave Rivers -

--
riv...@dignus.com                        Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to