🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12250

Re: Branchless conditionals (Was: More on Linpack pivoting)

#12250
From: Edward McClanahan
Date: Mon, 24 Jun 1991 19:50
48 lines
2276 bytes
|> :	    ibig  = absdx .le. dmax
|> 	    ^^^^^^^^^^^^^^^^^^^^^^^^
|> 
|> I would be very interested in seeing the assembler code that gets
|> emitted for this line of Fortran. How can this statement get executed
|> WITHOUT a branch??
|>  
|> I also have never seen a machine that has conditional assignment
|> implemented as an instruction! (As indicated above). What machine is
|> this? Could you show us the assembler syntax??
|> 
|> I ** believe ** that the above conditional assignment will get compiled
|> into a test and branch. I don't know of any machine that provides
|> instructions to do otherwise.

Just to add another example...

HP's RISC CPU (and many others) use conditionals to NULLIFY the next
instruction.  Here is how the HP compiler 'could' translate the above
statement:

Let's assume the compiler has made the following register assignments:

  R19 - ibig
  R20 - absdx
  R21 - dmax

The following three instruction sequence will store a ZERO in R19 (ibig)
if absdx > dmax (assuming that 1 means TRUE; I'm not a FORTRAN person)
and a ONE if absdx <= dmax:

  LDI    0,R19       ; Set ibig to 'default' of FALSE

  SUB,>  R20,R21,R0  ; 'Compare' absdx to dmax and NULLIFY next instruction
                     ;   if absdx > dmax
                     ; Result of subtraction is thrown away when sent to R0

  LDI    1,R19       ; If not NULLIFIED by 'SUB,>', set ibig to TRUE

Of course some may argue that this is really a branch...

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  Edward McClanahan
  Hewlett Packard Company     -or-     edwardm@cup.hp.com
  Mail Stop 42UN
  11000 Wolfe Road                     Phone: (408)447-5651
  Cupertino, CA  95014                 Fax:   (408)447-5039
Technical Details
Message-ID: <32580036@hpcuhe.cup.hp.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!hplabs!hpcc05!hpcuhb!hpcuhe!edwardm
References: <1991Jun14.173510.22510@dg-rtp.dg.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!hplabs!hpcc05!hpcuhb!hpcuhe!edwardm
From: edwardm@hpcuhe.cup.hp.com (Edward McClanahan)
Newsgroups: comp.arch
Subject: Re: Branchless conditionals (Was: More on Linpack pivoting)
Message-ID: <32580036@hpcuhe.cup.hp.com>
Date: 24 Jun 91 19:50:05 GMT
References: <1991Jun14.173510.22510@dg-rtp.dg.com>
Organization: Hewlett Packard, Cupertino
Lines: 48