Issue 162913
Summary [HLSL] A boolean vector as a result of logical NOT on an integer vector is sign-extended when converted back to an integer vector
Labels HLSL
Assignees
Reporter Icohedron
    A boolean vector as a result of logical NOT (`!`) on an integer vector is sign-extended when converted back to an integer vector.

## Reproduction

https://godbolt.org/z/hzarWGcoo

Given the following HLSL:
```hlsl
export uint32_t2 foo(uint32_t2 b) {
    return !b;
}

export uint32_t2 bar(uint32_t2 b) {
    return !bool2(b);
}
```

You would expect `foo` and `bar` to be equivalent. However, Clang produces the following IR:
```llvm
; RUN: clang-dxc -T lib_6_7 -Xclang -emit-llvm %s

define noundef range(i32 -1, 1) <2 x i32> @foo(unsigned int vector[2])(<2 x i32> noundef %0) local_unnamed_addr #0 {
 %2 = icmp eq <2 x i32> %0, zeroinitializer
  %3 = sext <2 x i1> %2 to <2 x i32>
  ret <2 x i32> %3
}

define noundef range(i32 0, 2) <2 x i32> @bar(unsigned int vector[2])(<2 x i32> noundef %0) local_unnamed_addr #0 {
 %2 = icmp eq <2 x i32> %0, zeroinitializer
  %3 = zext <2 x i1> %2 to <2 x i32>
  ret <2 x i32> %3
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to