[PATCH] D72794: [LegalizeDAG][Mips] Add an assert to protect a uint_to_fp implementation from double rounding. Add a i32->f32 uint_to_fp implementation that avoids this code.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 11:27:49 PST 2020


craig.topper created this revision.
craig.topper added reviewers: efriedma, uweigand, kpn, atanasyan.
Herald added subscribers: hiraditya, arichardson, sdardis.
Herald added a project: LLVM.
craig.topper edited the summary of this revision.

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.


https://reviews.llvm.org/D72794

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/test/CodeGen/Mips/uitofp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72794.238323.patch
Type: text/x-patch
Size: 4482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200115/6d8d4e5f/attachment.bin>


More information about the llvm-commits mailing list