Combining the thoughts engendered from about three replies, I wonder if
avoiding a branch as follows (on a processor which supports the
instructions) would perform better than branching.

LT  R0,CURRENT #LOAD CURRENT AND SET CC
SPM R1 #SAVE CC FROM LT
A R0,SUM #ADD SUM TO IT
IPM R1 #RESTORE CC FROM LT
STOC R0,SUM,NZ #STORE SUM ONLY IF CC OF LT WAS NZ

Basically this loads CURRENT into R0, setting the CC based on its value.
Then saves the CC in R1. Adds the SUM value into R0. Restores the CC from
the LT, because the Add destroyed it. Then only stores the result in SUM if
the CC is "Not Zero", as set by the LT. I don't know if this code avoid the
"cache thrashing" mention by Ed. I don't know if the CPU needs to "lock"
the cache line if the STOC is a NOP due to the CC being zero (from the LT)
most of the time (per the OP). I used R0 and R1 only because I tend to use
them, along with R14 and R15, as "junk" temporary registers.



-- 
Wasn't there something about a PASCAL programmer knowing the value of
everything and the Wirth of nothing?

Maranatha! <><
John McKown

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