Issue 162915
Summary [HLSL] Result of integer-vector and integer-vector multiplication is negated when one of the integer vectors is logical NOT'd
Labels HLSL
Assignees
Reporter Icohedron
    Result of integer-vector and integer-vector multiplication is incorrectly negated when one of the integer vectors is logical NOT'd (`!`).

## Reproduction

https://godbolt.org/z/n8zYee3W1

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

export uint32_t2 bar(uint32_t2 a, uint32_t2 b) {
    return a * !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 <2 x i32> @foo(unsigned int vector[2], unsigned int vector[2])(<2 x i32> noundef %0, <2 x i32> noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq <2 x i32> %1, zeroinitializer
 %4 = sub <2 x i32> zeroinitializer, %0
  %5 = select <2 x i1> %3, <2 x i32> %4, <2 x i32> zeroinitializer
  ret <2 x i32> %5
}

define noundef <2 x i32> @bar(unsigned int vector[2], unsigned int vector[2])(<2 x i32> noundef %0, <2 x i32> noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq <2 x i32> %1, zeroinitializer
  %4 = select <2 x i1> %3, <2 x i32> %0, <2 x i32> zeroinitializer
  ret <2 x i32> %4
}

attributes #0 = { alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to