For those concerned with the sub-optimal code generated by the compiler in my 
examples: FWIW, with OPT(2)

unsigned long long maxBit = 0x1ull << (arraySize-3);

compiles to

LGHI     r3,H'1'
...
LGR      r14,r1                 
...
AHI      r14,H'-3'              
SLLG     r14,r3,0(r14)          
STG      r14,#SPILL9(,r13,360) 

The loading of R1 is complex. It loads R1 as well as R14 with arraySize because 
it needs it for something else a couple of instructions later. 

It took me about ten minutes to find the instructions in question. Optimized 
object code has nothing resembling a line-by-line relationship with the source 
code.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Paul Gilmartin
Sent: Thursday, May 08, 2014 4:01 PM
To: [email protected]
Subject: Re: Another C compiler shift bug?

On Thu, 8 May 2014 15:35:39 -0700, Charles Mills  wrote:

>Hmmm. Well, I beat the compiler into submission ...
>
"beat"?  Actually I believe you lulled it into submission.

>    ...
>          SLDL     r2,0(r1)
>          LR       r0,r3
>          LR       r1,r2
>          ST       r1,maxBit(,r13,248)
>          ST       r0,maxBit(,r13,252)
>
Would there be anything wrong with:

          STM      r2,r3,maxBit+248(r13)

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to