home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.compilers      Compiler construction, theory, etc. (Mod      2,753 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,759 of 2,753   
   glen herrmannsfeldt to someone   
   Re: Switch statement code generation   
   04 Nov 09 08:51:49   
   
   From: gah@ugcs.caltech.edu   
      
   glen herrmannsfeldt  wrote:   
   (snip, someone wrote)   
      
   > [On machines with condition codes, I've seen binary searches expanded   
   > into code with compare and branch instructions; after the comparison   
   > you can do a three way branch on less, equal, or greater. -John]   
      
   I once saw in a Fortran book the suggestion that one use arithmetic   
   IF in place of computed GOTO with three labels.   
      
         IF(N-2) 1,2,3   
      
   instead of   
      
         GOTO (1,2,3),N   
      
   For modern processors depending on branch prediction logic,   
   either a branch table or address table will likely foil any   
   prediction system.  Complicated conditional branching is likely   
   faster in that case.   
      
   -- glen   
   [Hey, it worked great on the 709. -John]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca