home bbs files messages ]

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

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

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

   Message 2,864 of 4,675   
   Terje Mathisen to Melzzzzz   
   Re: Branching two check increment pays o   
   19 Jul 17 22:20:10   
   
   From: terje.mathisen@nospicedham.tmsw.no   
      
   Melzzzzz wrote:   
   > I have following code snippet:   
   >   
   >     cmp r9,1   
   >     je .one   
   >     add rdi,r9   
   >     sub rdx,r9   
   >     jmp .L0   
   > .one:   
   >     inc rdi   
   >     dec rdx   
   >     jmp .L0   
   >   
   > For some reason I did it like that and it seems that doesn't hurt, but   
   > gives significant boost in some cases?   
   > Am I doing it wrong or is this good practice?   
   >   
   That looks _really_ bad!   
      
   You must be hitting some weird interations, maybe with cache line   
   alignments?   
      
   The ADD and SUB instructions should never take more than a single cycle,   
   while the branch can miss and INC/DEC could also be slower than ADD/SUB   
   due to the need to specialcase the carry flag. (But no cpu version I   
   know about will actually run INC/DEC slower...)   
      
   Terje   
      
   --   
   -    
   "almost all programming can be viewed as an exercise in caching"   
      
   --- 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