Skip to content

[DirectX] Data scalarization pass does not account for struct types #166203

@inbelic

Description

@inbelic

Part of the data scalarization is to replace all uses of vectors with arrays.

Currently it will not account for vectors that are within a struct type, as struct types were explicitly ignored to resolve #145408.

This issue is resolved when a vector type embedded in a struct type is also converted to an array for alloca's and global variables.

From https://godbolt.org/z/bEqsT74nn:

%struct.RawStruct8D = type { [8 x <4 x i32> ] }

; CHECK: %struct.RawStruct8D.scalarized = type { [8 x [4 x i32]] }

define void @test_no_transform_of_struct()  {
entry:
  %outputSizesLocal.i = alloca %struct.RawStruct8D, align 4
  %arrayinit.element13.i76 = getelementptr inbounds nuw [1 x %struct.RawStruct8D], ptr %outputSizesLocal.i, i32 0, i32 0
  ; CHECK: %gep = getelementptr inbounds nuw [8 x [4 x i32] ] ...
  %arrayinit.element13.i76.i1 = getelementptr inbounds nuw [8 x <4 x i32>], ptr %arrayinit.element13.i76, i32 0, i32 1
    ret void
}

This was surfaced during implementation of #166200 and can be used as an example for test-cases.

Metadata

Metadata

Assignees

Type

Projects

Status

Active

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions