Set operation action for FP16 conversion opcodes, so the Op legalizer
can choose the gnu_* libcalls for Mips.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
[MIPS] OperationAction for FP_TO_FP16, FP16_TO_FP
Set operation action for FP16 conversion opcodes, so the Op legalizer
can choose the gnu_* libcalls for Mips.
This is related to http://reviews.llvm.org/D8755, which adds support to consider FP16 types as load/store-only types.
Do you need this for f64 as well? Also, please add some tests, to make sure we actually get to the libcalls.
Thanks for the patch and sorry for the delay in looking at it (we've just had two public holidays in the UK). The change looks right to me for f32 but as Ahmed says it needs a test case checking that it emits the call to the library.
Ok. I'll do that after I land http://reviews.llvm.org/D8755 since I'd need that to write tests for this patch.
- Added loadext and truncstore actions for f16
- Added tests to ensure that libcalls get inserted
LGTM with a small nit in the test.
lib/Target/Mips/MipsISelLowering.cpp | ||
---|---|---|
226–229 ↗ | (On Diff #23943) | While iterating, this will do 3 strange calls: setLoadExtAction(ISD::EXTLOAD, MVT::f16, MVT::f32, Expand); setLoadExtAction(ISD::EXTLOAD, MVT::f16, MVT::f16, Expand); setLoadExtAction(ISD::EXTLOAD, MVT::f32, MVT::f32, Expand); I assume it isn't a problem to do this since EXTLOAD doesn't make sense when the memory type is larger (or the same as) the value type. It might be better to list the valid cases like we do for setTruncStoreAction() below. I don't mind which approach is taken. |
test/CodeGen/Mips/fp16-promote.ll | ||
3–5 ↗ | (On Diff #23943) | Nit: These two lines aren't necessary and it's best not to duplicate the datalayout in the test in case we ever change it. The bit I think might change at some point is the vector part since our vectors only require the elements to be aligned and not the whole vector. |
64–71 ↗ | (On Diff #23943) | Just a comment, no change required: This might be a little fragile (the exact order of the output may vary) but I don't see a good way to make it more robust at the moment. |
Remove datalayout from the tests, and use CHECK-DAG for fpext_double test.
lib/Target/Mips/MipsISelLowering.cpp | ||
---|---|---|
226–229 ↗ | (On Diff #23943) | fp_valuetypes has larger FP types (f80, f128 etc). Enumerating all of them will be tedious and skipping these types is a divergence from current behavior. The only strange call introduced by this patch is the second one you listed. Such an EXTLOAD should never be generated, so I'll leave this as is. |
test/CodeGen/Mips/fp16-promote.ll | ||
3–5 ↗ | (On Diff #23943) | Done |
64–71 ↗ | (On Diff #23943) | I'll switch to CHECK-DAG for this test. It's still not robust enough, but is better than the current state. |
In future, please don't commit after a conditional LGTM if the conditions haven't been met. If you disagree with the conditions, you should discuss them further.
lib/Target/Mips/MipsISelLowering.cpp | ||
---|---|---|
226–229 ↗ | (On Diff #23943) |
Good point. Iterating makes sense in that case.
The first one is odd because it 'extends' from a f32 to a f16 which is actually a truncation operation. I do agree that such EXTLOAD's shouldn't be generated though. |
test/CodeGen/Mips/fp16-promote.ll | ||
64–71 ↗ | (On Diff #23943) | I didn't suggest CHECK-DAG here because it doesn't do what you'd expect when the match strings are the same. All the 'CHECK-LIBCALL-DAG: cvt.d.s' will match at the same position in the file (the first instance of 'cvt.d.s'). This is because the search for CHECK-DAG matches are all matched (starting from the same position in the file) before ordering violations are determined. For example, the following file will pass because both CHECK-DAG's match the same 'foo'. ; CHECK-DAG: fo{{o}} ; CHECK-DAG: fo{{o}} foo |
My apologies Daniel. I assumed an "Accepted" status in Phabricator carries over across minor updates, and that my last patch was minor. I was wrong on both counts. In the future, I'll wait for a LGTM on all patches.
I'll address the CHECK-DAG concern in a different patch and link it back to here.
test/CodeGen/Mips/fp16-promote.ll | ||
---|---|---|
64–71 ↗ | (On Diff #23943) | You are right. In fact, I found out about this in a different context, but missed it here. I think the right thing to do here is to change CHECK-DAG to CHECK and add a comment noting the fragility of this test. |
No worries. It turned out that I agreed with most of your replies anyway :-).
I'll address the CHECK-DAG concern in a different patch and link it back to
here.
Sounds good to me. Thanks.