This patch fixes the lowering of uitofp and fptoui. For out of range values to fptoui and uitofp we perform fixups so that the result value is correct.
This patch is based on work by Simon Dardis.
Paths
| Differential D30678
[MIPS] Fix uitofp and fptoui for vector and scalar types Needs ReviewPublic Authored by sdardis on Mar 6 2017, 10:23 PM.
Details
Summary This patch fixes the lowering of uitofp and fptoui. For out of range values to fptoui and uitofp we perform fixups so that the result value is correct. This patch is based on work by Simon Dardis.
Diff Detail
Event TimelineComment Actions Comments inlined. I'm concerned that the legalization action of fp_to_uint is incorrect given the differences between the output of LLVM and GCC, in addition to the difference in the lowering of the i32 and i64 types. Additionally, some of the new emit*() functions are producing bad machine code due to differences in register classes/instructions for MIPS32 / MIPS64. You can find the problems by running the test cases with -verify-machineinstrs. With -verify-machineinstrs, two of the bad machine code errors refer to mtc1 / mfc1. You can ignore them for the purposes of this patch, this is an outstanding bug with LLVM for MIPS, as those instructions need definitions for the AFGR64 and FGR64 register classes.
This revision now requires changes to proceed.Apr 7 2017, 6:09 AM slthakur edited edge metadata. slthakur marked 15 inline comments as done. Comment ActionsAddressed review comments Comment Actions Comments inlined. I'm concerned about two things in this patch, the handling of FP_TO_UINT which lowers as if it was FP_TO_SINT and the sequences which perform correction for negative values.
This revision now requires changes to proceed.May 8 2017, 5:21 AM slthakur edited edge metadata. slthakur marked 13 inline comments as done. Comment ActionsAddressed review comments. Sorry for the delay.
Comment Actions Comments inlined. Most of them are small nits. The big change required is that you need to provide a target DAGCombine to produce the pseudos for later expansion on mips32r2 with a 64 bit fpu.
This revision now requires changes to proceed.Jun 16 2017, 4:34 AM slthakur edited edge metadata. slthakur marked 18 inline comments as done. Comment ActionsAddressed review comments and re-synced with TOT.
Revision Contents
Diff 107485 lib/Target/Mips/MipsISelLowering.cpp
lib/Target/Mips/MipsInstrFPU.td
lib/Target/Mips/MipsMSAInstrInfo.td
lib/Target/Mips/MipsSEISelLowering.h
lib/Target/Mips/MipsSEISelLowering.cpp
test/CodeGen/Mips/2008-07-07-Float2Int.lltest/CodeGen/Mips/cconv/vector.ll
test/CodeGen/Mips/mips64-f128.ll
test/CodeGen/Mips/msa/f16-llvm-ir.ll
|
This looks incorrect. The associated lowering calls lowerFP_TO_SINT for the conversion of a floating point value to an unsigned integer. It also wildly differs from the output of gcc.