llvm-project
040e24b0 - [DAGCombiner][GlobalISel] Fold floor into unsigned FP-to-int conversions (#239233)

Commit
14 hours ago
[DAGCombiner][GlobalISel] Fold floor into unsigned FP-to-int conversions (#239233) Add shared SelectionDAG/GlobalISel combines to eliminate floors before unsigned FP-to-int conversions. * IR conversion is equivalent (reusing an existing comment): https://github.com/llvm/llvm-project/pull/231060#issuecomment-6120567356 * Removing the floor is a refinement for `fptoui` and preserves the result for `fptoui.sat`. * Shared floors are allowed, following #231060. This can enable tail calls but can also introduce spills when the floor is a libcall. * `InstCombine` could have this pattern as well, but AMDGPU lowering explicitly creates a floor with two users, so these combines are still useful. Updated existing codegen checks for: * `f32 -> u32`, `f64 -> u32`, and `f16 -> u16` * 64-bit results, saturation, and vectors * source modifiers and the normal, true16, and fake16 variants ## Related * handles `trunc` before conversion, and complementary to this: https://github.com/llvm/llvm-project/pull/231060 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Author
Parents
Loading