[LLVMdev] types in load/store

Duncan Sands baldrick at free.fr
Thu Jul 8 08:49:05 PDT 2010

Hi Jianzhou,

> The other question is about 'when loading a value of a type like i20
> with a size that is not an integral number of bytes, the result is
> undefined if the value was not originally written using a store of the
> same type'. At this case, can we make an assumption that typically we
> only load the 20 bits, but ignore extra bits, like what store does at
> such a case. Is there any problem that stops such an assumption´╝č

the way the code generators currently work is that when you store an
i20, three bytes are written: your 20 bits followed by 4 zero bits.
When an i20 is loaded, which means loading three bytes, the code
generators "know" that the extra 4 bits must be zero, and may perform
some simplifications based on this knowledge.  If you store three bytes,
and bits 20 to 23 are not zero, and you try to load it as an i20, you
may therefore get strange results due to such simplifications.



PS: The fact that the extra stored bits are zero shouldn't be relied
upon, since it may change in the future.

More information about the llvm-dev mailing list