public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Packing booleans?
@ 2005-05-04  7:51 Sam Lauber
  2005-05-04 10:55 ` Nathan Sidwell
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Sam Lauber @ 2005-05-04  7:51 UTC (permalink / raw)
  To: gcc

Would it be possible to have a -fpack-bools option that packs booleans into
the smallest form possible (8 booleans -> 1 8-bit reg, etc.) into a register
(or memory, as the case may be)?

Samuel Lauber
-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
  2005-05-04  7:51 Packing booleans? Sam Lauber
@ 2005-05-04 10:55 ` Nathan Sidwell
  2005-05-04 12:25   ` Mattias Karlsson
  2005-05-04 12:22 ` Nix
  2005-05-04 12:31 ` Richard Guenther
  2 siblings, 1 reply; 8+ messages in thread
From: Nathan Sidwell @ 2005-05-04 10:55 UTC (permalink / raw)
  To: Sam Lauber; +Cc: gcc

Sam Lauber wrote:
> Would it be possible to have a -fpack-bools option that packs booleans into
> the smallest form possible (8 booleans -> 1 8-bit reg, etc.) into a register
> (or memory, as the case may be)?

why would you want to do this?  Seems to me you might save up to 7 bytes
of data memory at a vastly greater expansion of code size and reduction
in performance.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
  2005-05-04  7:51 Packing booleans? Sam Lauber
  2005-05-04 10:55 ` Nathan Sidwell
@ 2005-05-04 12:22 ` Nix
  2005-05-04 12:31 ` Richard Guenther
  2 siblings, 0 replies; 8+ messages in thread
From: Nix @ 2005-05-04 12:22 UTC (permalink / raw)
  To: Sam Lauber; +Cc: gcc

On 4 May 2005, Sam Lauber stipulated:
> Would it be possible to have a -fpack-bools option that packs booleans into
> the smallest form possible (8 booleans -> 1 8-bit reg, etc.) into a register
> (or memory, as the case may be)?

How could you do that without breaking the semantics of the program?

Among other things, you couldn't take the address of such a packed
boolean: if the idea is to quietly suppress boolean packing for booleans
whose address is taken, then this will suppress packing for any boolean
shared between translation units, or possibly even between procedures.

-- 
`End users are just test loads for verifying that the system works, kind of
 like resistors in an electrical circuit.' - Kaz Kylheku in c.o.l.d.s

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
  2005-05-04 10:55 ` Nathan Sidwell
@ 2005-05-04 12:25   ` Mattias Karlsson
  2005-05-04 12:57     ` Nathan Sidwell
  0 siblings, 1 reply; 8+ messages in thread
From: Mattias Karlsson @ 2005-05-04 12:25 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: Sam Lauber, gcc

On Wed, 4 May 2005, Nathan Sidwell wrote:

> Sam Lauber wrote:
>> Would it be possible to have a -fpack-bools option that packs booleans into
>> the smallest form possible (8 booleans -> 1 8-bit reg, etc.) into a 
>> register
>> (or memory, as the case may be)?
>
> why would you want to do this?  Seems to me you might save up to 7 bytes
> of data memory at a vastly greater expansion of code size and reduction
> in performance.

Unless you are using an architecture with btst, bset, bclr instructions.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
  2005-05-04  7:51 Packing booleans? Sam Lauber
  2005-05-04 10:55 ` Nathan Sidwell
  2005-05-04 12:22 ` Nix
@ 2005-05-04 12:31 ` Richard Guenther
  2 siblings, 0 replies; 8+ messages in thread
From: Richard Guenther @ 2005-05-04 12:31 UTC (permalink / raw)
  To: Sam Lauber; +Cc: gcc

On 5/4/05, Sam Lauber <sam124@operamail.com> wrote:
> Would it be possible to have a -fpack-bools option that packs booleans into
> the smallest form possible (8 booleans -> 1 8-bit reg, etc.) into a register
> (or memory, as the case may be)?

Why don't you use bitfields then?

Richard.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
  2005-05-04 12:25   ` Mattias Karlsson
@ 2005-05-04 12:57     ` Nathan Sidwell
  0 siblings, 0 replies; 8+ messages in thread
From: Nathan Sidwell @ 2005-05-04 12:57 UTC (permalink / raw)
  To: Mattias Karlsson; +Cc: Sam Lauber, gcc

Mattias Karlsson wrote:
> On Wed, 4 May 2005, Nathan Sidwell wrote:
> 
>> Sam Lauber wrote:
>>
>>> Would it be possible to have a -fpack-bools option that packs 
>>> booleans into
>>> the smallest form possible (8 booleans -> 1 8-bit reg, etc.) into a 
>>> register
>>> (or memory, as the case may be)?
>>
>>
>> why would you want to do this?  Seems to me you might save up to 7 bytes
>> of data memory at a vastly greater expansion of code size and reduction
>> in performance.
> 
> 
> Unless you are using an architecture with btst, bset, bclr instructions.

True, they'd have to have memory operands to be a win though. Otherwise it'd
be a
	load
	bset
	store
or
	load
	btst
sequence, rather than
	store
or
	load

Of course, one might be able to amortize the load and store over several
bit operations, but you'd still end up with at least one extra instruction
over not packing, and that will cost you 4 bytes (or thereabouts).

If this were being done at the level of register allocation, why would
one need a user visible option?  'Just' rearrange the register file to look
like a set of single bit registers overlaid on a more conventional register
file.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
@ 2005-05-05  2:35 Sam Lauber
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Lauber @ 2005-05-05  2:35 UTC (permalink / raw)
  To: gcc

> If this were being done at the level of register allocation, why would
> one need a user visible option?  'Just' rearrange the register file to look
> like a set of single bit registers overlaid on a more conventional register
> file.
As someone pointed out, this might change semantics (read: screw up ;-)
of the * and & operators: &somebool, though it would be placed into memory,
wouldn't deserve an address, since most[1] architechures aren't bit-
adressable.  

Samuel Lauber

[1] I said ``some'', not ``all'', because the TMS340x0 port is.  
-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Packing booleans?
@ 2005-05-05  1:58 Sam Lauber
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Lauber @ 2005-05-05  1:58 UTC (permalink / raw)
  To: gcc

> Unless you are using an architecture with btst, bset, bclr instructions.
Pretty much any architechure that could be called a binary computer has 
something like that ;-)

Samuel Lauber
-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com

Powered by Outblaze

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-05-05  1:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-04  7:51 Packing booleans? Sam Lauber
2005-05-04 10:55 ` Nathan Sidwell
2005-05-04 12:25   ` Mattias Karlsson
2005-05-04 12:57     ` Nathan Sidwell
2005-05-04 12:22 ` Nix
2005-05-04 12:31 ` Richard Guenther
2005-05-05  1:58 Sam Lauber
2005-05-05  2:35 Sam Lauber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).