Summary
When lowering min-precision buffer stores in HLOperationLower.cpp, signedness information (min16int vs min16uint) has been lost — both are just i16 in the IR. This means the widening cast from i16 to i32 must choose between SExt and ZExt without knowing which is correct.
Current Behavior
The store widening in TranslateStore uses SExt unconditionally, which is wrong for min16uint values.
The existing TranslateMinPrecisionRawBuffer pass in DxilGenerationPass.cpp handles this for RawBufferStore by recovering signedness from DxilStructAnnotation / CompType metadata. However, RawBufferVectorStore (SM 6.9+) has no equivalent handling.
Proposed Fix
As suggested by @tex3d in #8274 (comment):
The front-end during Clang CodeGen should generate the widening cast (to full-precision i32/f32) at the point where the high-level store op is created, so that the store already uses a full-precision type. At that stage, QualType signedness is still available, making it straightforward to emit the correct SExt (signed) or ZExt (unsigned).
Context
Summary
When lowering min-precision buffer stores in
HLOperationLower.cpp, signedness information (min16intvsmin16uint) has been lost — both are justi16in the IR. This means the widening cast fromi16toi32must choose betweenSExtandZExtwithout knowing which is correct.Current Behavior
The store widening in
TranslateStoreusesSExtunconditionally, which is wrong formin16uintvalues.The existing
TranslateMinPrecisionRawBufferpass inDxilGenerationPass.cpphandles this forRawBufferStoreby recovering signedness fromDxilStructAnnotation/CompTypemetadata. However,RawBufferVectorStore(SM 6.9+) has no equivalent handling.Proposed Fix
As suggested by @tex3d in #8274 (comment):
The front-end during Clang CodeGen should generate the widening cast (to full-precision
i32/f32) at the point where the high-level store op is created, so that the store already uses a full-precision type. At that stage,QualTypesignedness is still available, making it straightforward to emit the correctSExt(signed) orZExt(unsigned).Context
RawBufferVectorStoreandRawBufferStoreinHLOperationLower.cppSExt/ZExtambiguity is marked with a TODO referencing this issue