The algorithm here only works if the sint_to_fp doesn't do any rounding. Otherwise it can round before the offset fixup is applied. Add an assert to protect this.
One test in tree was using this code for i32->f32 when f64 isn't legal. That test was only checking for not crashing until an earlier commit today. I've added a i32->f32 conversion using the same code as i64->f32 from TargetLowering. This is similar to what Mips gcc does for this config according to godbolt except they use control flow instead of selects. We should merge the new code with the code in TargetLowering, but the order of things is a little tricky right now. We call TLI first, then some code earlier in LegalizeDAG that tries to use i32->f32 by using i32->f64->f32. This new i32->f32 needs to be lower priority than i32->f64->f32. So I'm focusing on correctness first before refactoring this.