[LLVM][IR] LLVM fails to optimize saturated float conversion expressions down to @llvm.fptosi.sat/@llvm.fptoui.sat calls
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Here is a link to an LLVM IR snippet showing LLVM failing to optimize saturated float conversion expressions to @llvm.fptosi.sat/@llvm.fptoui.sat:
https://alive2.llvm.org/ce/z/id6gSA
Here are the equivalent C expressions that LLVM fails to optimize to @llvm.fptosi.sat/@llvm.fptoui.sat:
- F32 to I32: `(x >= 2147483648.0f) ? INT32_MAX : ((x >= -2147483648.0f) ? (int32_t)x : ((x == x) ? INT32_MIN : 0))`
- F32 to U32: `(x >= 4294967296.0f) ? UINT32_MAX : ((x >= 0.0f) ? (uint32_t)x : 0)`
- F64 to I32: `(x > 2147483647.0) ? INT32_MAX : ((x >= -2147483648.0) ? (int32_t)x : ((x == x) ? INT32_MIN : 0))`
- F64 to U32: `(x > 4294967295.0) ? UINT32_MAX : ((x >= 0.0) ? (uint32_t)x : 0)`
Contributor guide
Assessment
This issue has not been assessed yet.