[Freeciv-Dev] Re: (PR#2521) general effects framework
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Generally, assignments are not the common use case. It might be
more instructive to see what various expressions code looked like.
It is quite possible the compiler will use bit test operations.
Also, most of the noise below is a result of the widening or
narrowing of the values during assignment, i.e. int conversion.
If you changed the ints to bools, it might reduce a lot of the
noise ops. Presumably the compiler knows a bool is 1 bit no
matter what the storage size and will forgo a lot of the extra
bit clearing and extending steps.
But I'm surprised it first clears, then ors the bit on set. It
should be able to get away with `orb %al, s`.
If it knew the arg was a bool, it could get away with the first,
3rd and above instruction on a set.
movb 8(%ebp),%al
salb $6,%al
orb %al,s
On get, it is also intriguing that it first shifts up to the
sign bit and then downshifts to propagate an all ones or zeros.
On a get it could get away with something like this
bt $6,s
setc %al
Cheers,
RossW
=====
Mike Kaufman wrote:
> On Tue, Mar 11, 2003 at 08:51:22AM -0800, Raimar Falke wrote:
>
>>Do you have numbers which show that this reduces the execution time?
>>Accessing them is not as cheap as you may think:
>>
>>void g(int x)
>>{
>> s.has.gov=x;
>>}
>>
>>generates:
>> movb 8(%ebp),%al
>> andb $1,%al
>> salb $6,%al
>> movb s,%dl
>> andb $191,%dl
>> orb %al,%dl
>> movb %dl,s
>>
>>and
>>int g(void)
>>{
>> return s.has.adv;
>>}
>>
>> movb s,%al
>> salb $2,%al
>> sarb $7,%al
>> movsbl %al,%eax
>>
>>A lot of instructions for an assignment. Using the bool type may increase
>>the cache pressure but may speed the execution up. I don't know which one is
>>faster but it isn't obvious to me that the bitfields are the better choice.
>
>
> hmm. well, right now the struct uses 4 bytes. switching to unsigned char
> moves the number to 9 bytes (maybe 8 if can eliminate was_active).
> If I use bool, I need 36 bytes. That's unacceptable. made fc_bool an
> unsigned char and I'll use it. So for now, I'll change this to unsigned
> char as speed here is important.
>
> -mike
- [Freeciv-Dev] (PR#2521) general effects framework, Mike Kaufman, 2003/03/10
- Message not available
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Mike Kaufman, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Mike Kaufman, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Mike Kaufman, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/11
- [Freeciv-Dev] Re: (PR#2521) general effects framework,
rwetmore@xxxxxxxxxxxx <=
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/12
- [Freeciv-Dev] Re: (PR#2521) general effects framework, rwetmore@xxxxxxxxxxxx, 2003/03/12
- [Freeciv-Dev] Re: (PR#2521) general effects framework, Raimar Falke, 2003/03/13
|
|