Skip to content

Front-end should widen min-precision stores to full precision during Clang CodeGen #8314

@alsepkow

Description

@alsepkow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions