Issue 168944
Summary [Matrix][HLSL] update IsSameFloatAfterCast to support Matrix type
Labels clang:frontend, HLSL
Assignees
Reporter farzonl
    The current code is:
```cpp
static bool IsSameFloatAfterCast(const APValue &value,
                                 const llvm::fltSemantics &Src,
 const llvm::fltSemantics &Tgt) {
  if (value.isFloat())
    return IsSameFloatAfterCast(value.getFloat(), Src, Tgt);

  if (value.isVector()) {
    for (unsigned i = 0, e = value.getVectorLength(); i != e; ++i)
      if (!IsSameFloatAfterCast(value.getVectorElt(i), Src, Tgt))
        return false;
    return true;
  }

  assert(value.isComplexFloat());
  return (IsSameFloatAfterCast(value.getComplexFloatReal(), Src, Tgt) &&
 IsSameFloatAfterCast(value.getComplexFloatImag(), Src, Tgt));
}
```

The problem here is if we don't update this function We can't properly warn about implicit conversion lose for this HLSL code:
```hlsl
void Half(half2x2 H);
void Case7(half2x2 H, float2x2 F, double2x2 D) {
 Half(F); // expected-warning{{implicit conversion loses floating-point precision: 'float2x2' (aka 'matrix<float, 2, 2>') to 'matrix<half, 2, 2>' (matrix of 4 'half' values)}}

  Half(D); // expected-warning{{implicit conversion loses floating-point precision: 'double2x2' (aka 'matrix<double, 2, 2>') to 'matrix<half, 2, 2>' (vector of 4 'half' values)}}
}
```

However we can't implement this ticket until we implment this one #168935

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to