[llvm] [LangRef] Specify semantics for non-byte-sized loads and stores (PR #180739)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 11 05:16:29 PST 2026
bjope wrote:
I wonder if it really should be "trunc nuw" on the load. Then you can't do type punning by having a union with i16 and i12 for example, storing an i16 value and then loading i12. But maybe the reasoning is that such things shouldn't be well defined for any target anyway?
In the past it was kind of unspecified in the LangRef (so basically target dependant) if you for example would get the most significant or least significant bits of the i16. At least that has been my interpretation of the old wordning (that on IR level you do not know where the padding bits go, so optimizers should not assume things about that). By only saying "trunc" we define where the significant bits go. That is probably ok for 99.9% of all targets. But I wonder if saying "trunc nuw" may cause more problems.
Or is the idea that frontends should do like this: https://godbolt.org/z/7qnoWdMo7
That is to not use load i12 in the first place. In that example we do get a "trunc" rather than "trunc nuw".
(Unfortunately our downstream frontend currently emit loads/stores of non-byte-sized types. So that is why the "nuw" part is making me a bit worried.)
https://github.com/llvm/llvm-project/pull/180739
More information about the llvm-commits
mailing list