[clang] [HLSL] Shore up floating point conversions (PR #90222)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 12:09:29 PDT 2024


================
@@ -2616,6 +2617,13 @@ bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
            ToBuiltin->getKind() == BuiltinType::Ibm128))
         return true;
 
+      // In HLSL, `half` promotes to `float` or `double`, regardless of whether
+      // or not native half types are enabled.
----------------
llvm-beanz wrote:

There is a difference between the IR and language types. `half` is always `half` in the language, which is always a different type form `float`. This behavior is consistent in earlier language modes and with 202x:

https://godbolt.org/z/3bzoocdrG

When you don't pass `-enable-16bit-types`, `half` is 32-bit and conforms to the IEEE single-precision fp32 representation (see: https://github.com/llvm/llvm-project/pull/90694).


https://github.com/llvm/llvm-project/pull/90222


More information about the cfe-commits mailing list