Skip to content

[linalg] matrix alloca from loop-unroll #8624

Description

@haosu-nv

notice dxc 's loop-unroll materialize a linalg matrix value to stack,

    c.MultiplyAccumulate(a, b);
    [unroll]
    for (uint slot = 0; slot < 8; ++slot) {
        const uint2 coordinate = c.GetCoordinate(slot);
        Output.Store((coordinate.x * 128 + coordinate.y) * 4,
                     0);
    }

emit dxil

%37 = alloca %dx.types.LinAlgMatrixC9M64N128U2S2, align 8
%51 = call %dx.types.LinAlgMatrixC9M64N128U2S2 @dx.op.linAlgMatrixMultiplyAccumulate....
store %dx.types.LinAlgMatrixC9M64N128U2S2 %51, ptr %37, align 8
...
%66 = load %dx.types.LinAlgMatrixC9M64N128U2S2, ptr %37, align 8, !tbaa !27
%67 = call <2xi32> @dx.op.linAlgMatrixGetCoordinate(i32, %dx.types.LinAlgMatrix %66, i32 1)

this is incorrect dxil by spec, as a linalg matrix %66 was defined by load instead of dx.op.LinalgMatrixMulAdd.
A WAR solution would be running PromoteMemToReg by detecting an alloca of matrix ref, after all optimization passes.

Metadata

Metadata

Labels

bugBug, regression, crashneeds-triageAwaiting triage

Type

No type

Projects

Status
Triaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions