Author: Dezhi Zhao
Date: 09:34:42 01/16/99
Go up one level in this thread
On January 16, 1999 at 11:13:43, Robert Hyatt wrote: >On January 16, 1999 at 07:27:53, Dezhi Zhao wrote: [snip] >>Apparently there is no register renaming facility for VC compiler to >>make the asm function to be inlined. > >get the crafty source and look at x86.c... you can inline asm routines >quite easily. That file has the stuff needed to do it... > >Bob Dr. Hyatt: sorry! I did not express myself clearly here. I mean VC the compiler does not make the asm function inlined in the way it should be. Yes, an asm function can behave as a micro and save a function calls. But the inlined code do have some unwanted overhead, extra save/reload instructions. I did read Mr. Nalimov's asm functions in Crafty mailing list. However if you inline them in to your existing C functions, I think you will produce the same effect and the same side effect as I described in the previous post as follows: >> >>int big_bsf_caller() >>{ >> // ..... many stuff before we need bsf/ bsr >> >> int bitstring; >> >> //... map is set after some calculations >> >> int first_one; >> _asm bsf first_one , bitstring >> >> >> // ..... many stuff after we used bsf/ bsr >>} >> >>It works but is even worse than the function approach. After reading the >>VC-generated asm code, I found that bitstring is treated as a mem operand >>in the bsf operation even though bitstring was in fact in a register before >>the operation. The complier moves the value of the register representing >>bitstring back into stack and generates bsf reg, [esp + 8] alike instruction! >>And I found the embedded instruction does harm the caller in terms of >>optimizations (bad register uasage), as the documation suggests. >>This experiment was done 1 year ago with VC5. This is probably still true >>for VC6. >> >>Sure, one could write big_bsf_caller() all in inline asm, but that only >>hardens the design too early. >> It seems to me that the asm function should not be inlined if the C caller is complex enough. The compiler just pastes the asm lines into the generated code. The asm instructions use fixed registers , that affects the complier's decision on register useage. Dezhi Zhao
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.