Issue 175236
Summary [HLSL][Matrix] Parameter declarations for boolean (i1) matrices are not ZExt to i32 before initial store to alloca
Labels HLSL
Assignees
Reporter Icohedron
    Parameter declarations for boolean (i1) matrices are not ZExt to i32 before initial store to alloca as observed in the following example.
Boolean vectors have the ZExt, but boolean matrices currently do not.

https://hlsl.godbolt.org/z/n1K17Y1xq

```hlsl
export bool4x4 testMat(bool4x4 m) {
    return m;
}

export bool4 testVec(bool4 v) {
 return v;
}
```

```llvm
; Function Attrs: alwaysinline convergent mustprogress norecurse nounwind
define noundef <16 x i1> @_Z7testMatu11matrix_typeILm4ELm4EbE(<16 x i1> noundef %m) #0 {
entry:
 %retval = alloca <16 x i1>, align 4
  %m.addr = alloca [16 x i32], align 4
 store <16 x i1> %m, ptr %m.addr, align 4 ; <-- directly storing <16 x i1> to alloca [16 x i32]
  %0 = load <16 x i32>, ptr %m.addr, align 4
  store <16 x i32> %0, ptr %retval, align 4 ; (missing a trunc here, but this is not relevant for this issue)
  %1 = load <16 x i1>, ptr %retval, align 4
  ret <16 x i1> %1
}

; Function Attrs: alwaysinline convergent mustprogress norecurse nounwind
define noundef <4 x i1> @testVec(bool vector[4])(<4 x i1> noundef %v) #0 {
entry:
  %v.addr = alloca <4 x i32>, align 16
  %0 = zext <4 x i1> %v to <4 x i32> ; <-- <4 x i1> is zext to <4 x i32> before store
 store <4 x i32> %0, ptr %v.addr, align 16
  %1 = load <4 x i32>, ptr %v.addr, align 16
  %loadedv = trunc <4 x i32> %1 to <4 x i1>
  ret <4 x i1> %loadedv
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to