[llvm-dev] What should a truncating store do?
Friedman, Eli via llvm-dev
llvm-dev at lists.llvm.org
Wed May 9 11:16:17 PDT 2018
On 5/9/2018 9:54 AM, Tom Stellard wrote:
> On 09/15/2017 10:55 AM, Friedman, Eli via llvm-dev wrote:
>> On 9/15/2017 5:49 AM, Jon Chesterfield via llvm-dev wrote:
>>> For example, truncating store of an i32 to i6. My assumption was that this should write the low six bits of the i32 to somewhere in memory.
>>>
>>> Should the top 24 bits of a corresponding 32 bit region of memory be unchanged, zero, undefined?
>> Unchanged.
>>
>>> Should the two bits that would round the i6 up to a byte be preserved, zero, undefined?
>> Zero. Legalization will normally handle this for you, though, by transforming it to an i8 store.
>>
> Why is this Zero? The language ref says the value of those bits are
> unspecified.
Zero, because that makes it more convenient to lower the corresponding
"load" instruction. Note the corresponding language for loads: "When
loading a value of a type likei20with 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."
Maybe we should fix the bits to zero instead, to match what happens in
practice.
-Eli
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180509/353fd874/attachment.html>
More information about the llvm-dev
mailing list