Skip to content

[DirectX] GEPs from memset and memcpy legalization fail to validate due to Explicit load/store type does not match pointee type of pointer operand #148089

@Icohedron

Description

@Icohedron

After fixing #147114 I noticed there were still instances of the Explicit load/store type does not match pointee type of pointer operand validation error.

There are up to 78 DML shaders failing to validate due to GEPs introduced by memset and memcpy legalization in DXILLegalizePass.cpp

The memset and memcpy legalizations need to be modified to produce well-formed GEPs for LLVM 3.7 / DXIL.

Example affected DML shader: Cast_float16_native_accum16_uint8_packed32_256_Strided4D.dat

Sample shader reproducing the issue: https://godbolt.org/z/68T5fWvfG

RWStructuredBuffer<uint32_t> output;
[numthreads(1, 1, 1)]
void CSMain(uint3 dtid : SV_DispatchThreadId) {
  uint32_t bar = 0;
  for (uint i = 0; i < 2; i++) {
    bool baz = false;
    uint foo[] = {0, 0, 0};
    for (uint j = dtid.x; j; j--)
      baz = baz || foo[j];
    if (baz)
      bar = i;
  }
  output[0] = bar;
}

-mllvm -stop-before=dxil-legalize

  %1 = alloca [3 x i32], align 4, !DIAssignID !55
  ...
  call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(12) %1, i8 0, i32 12, i1 false), !dbg !104, !DIAssignID !101

-mllvm -stop-after=dxil-legalize

  %1 = alloca [3 x i32], align 4, !DIAssignID !55
  ...
  %5 = getelementptr i32, ptr %1, i32 0, !dbg !104
  store i32 0, ptr %5, align 4, !dbg !104
  %6 = getelementptr i32, ptr %1, i32 1, !dbg !104
  store i32 0, ptr %6, align 4, !dbg !104
  %7 = getelementptr i32, ptr %1, i32 2, !dbg !104
  store i32 0, ptr %7, align 4, !dbg !104

Validation error

Explicit gep type does not match pointee type of pointer operand
Validation failed.

The issue is that the GEPs use a scalar (i32) type to index an array-typed ([3 x i32]) pointer operand.

Metadata

Metadata

Assignees

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions