[cfe-commits] [pr12251][patch] Use i1* for boolean loads and stores

Chris Lattner clattner at apple.com
Tue Mar 13 14:51:10 PDT 2012


On Mar 13, 2012, at 1:21 PM, Rafael EspĂ­ndola wrote:

>> the language ref currently says that it is undefined what gets stored in the
>> other 7 bits when you write an i1.  That was just to give freedom to be
>> efficient, but should be changed to say "target dependent" or something like
>> that if you want to go this way.
> 
> Good point. I noticed the store had to be i1 for the i1 load to be
> legal, but I missed this one.

I really don't like "store of i1" having target-dependent semantics.  If the real issue here is that we have no way to represent a "byte load that is known to be all ones at the top part" then we should add support for that directly IMO.

Doing this should be relatively straightforward: just add a per-instruction metadata that indicates the number of leading zero bits that ComputeMaskedBits and friends can use.  The hard part is designing something that is suitably general to capture other interesting properties.

>> There are also some real problems.  First off, writing an i1 will only ever
>> write a byte, but doesn't ppc or some platform like that use 32 bit
>> booleans?
> 
> I know they exist, but not much more (I don't know even if they are
> supported). There are two possible cases:
> 
> * They use any non zero value as true. This optimization doesn't apply
> at all and we should use the current approach.

This would violate the ABI.  The relevant ABIs really want 0 or 1 in  the bool unit, even if it is 32-bits.

-Chris





More information about the cfe-commits mailing list