Open thevaber opened 1 week ago
@llvm-beanz - it might be interesting to see what the language spec says about this.
For the SPIR-V codegen side, seems like there is a slight mismatch between how we handle implicit casts (first is an IntegralCast), vs the explicit cast from float -> int -> uint.
Waiting on MS answer on what the spec says before fixing one side or the other.
I'm not too concerned about the spec in this case. It would be unreasonable that the cast to int
could be elided with the case to uint
making it undefined. The AST has all of the correct casts, and the spir-v should reflect that.
Description The compiler generates a float->uint conversion (
OpConvertFToU
instruction) when trying to convert float->int->uint (which should result inOpConvertFToS
followed byOpBitcast
) - sinceOpConvertFToU
is as far as I can tell not defined for negative float values (and hardware seems to convert negative floats to 0u), the two operations are not equivalent, and the behavior is different than expected for negative values.Steps to Reproduce
(https://godbolt.org/z/1sb68E8b1)
Environment All DXC versions currently available via godbolt.org