| Issue |
182433
|
| Summary |
APFloat::convert() followed by bitcastToAPInt() crashes when converting infinity to FiniteOnly semantics (e.g. Float4E2M1FN)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
blinxt
|
## Summary
APFloat::convert() followed by bitcastToAPInt() crashes with UNREACHABLE when the source value is infinity and the target semantics has fltNonfiniteBehavior::FiniteOnly (e.g. Float4E2M1FN).
```
semantics don't support inf!
UNREACHABLE executed at llvm/lib/Support/APFloat.cpp
```
## Repro
```
#include <llvm/ADT/APFloat.h>
using namespace llvm;
int main() {
APFloat val(1.0 / 0.0); // +inf
bool losesInfo;
val.convert(APFloat::Float4E2M1FN(), APFloat::rmNearestTiesToEven, &losesInfo);
APInt bits = val.bitcastToAPInt(); // UNREACHABLE
}
```
## Expected Behavior
Converting infinity into a FiniteOnly format should produce a valid result (e.g. saturate to the largest magnitude and preserve sign), according to https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs