This is an archive of the discontinued LLVM Phabricator instance.

[RISC-V] Do not crash when using -ftrapping-math
Needs ReviewPublic

Authored by kamleshbhalui on Jun 8 2020, 7:02 AM.

Details

Summary

When using clang option -frapping-math, RISC-V backend crash.
This patch enable Lowering for strictp in riscv to get rid of crash.

Diff Detail

Event Timeline

kamleshbhalui created this revision.Jun 8 2020, 7:02 AM
luismarques added inline comments.Jun 8 2020, 7:34 AM
llvm/test/CodeGen/RISCV/fp-strict.ll
3–6

It's probably a good idea to use the hardfloat ABI, to cut down on the amount of GPR to FPR conversion instructions, etc.

132

Shouldn't this test also have an fcmps oeq case, showing the proper behavior in terms of NaN signaling, by using the correct RISC-V instruction for that? I haven't yet delved into the lowerSETCC implementation but it seems that having such tests here would clarify if this is correctly implemented.

kamleshbhalui marked an inline comment as done.Jun 8 2020, 8:28 AM
kamleshbhalui added inline comments.
llvm/test/CodeGen/RISCV/fp-strict.ll
3–6

thanks , will consider it in next diff update.

asb added a comment.Jun 9 2020, 12:58 AM

Disclaimer: I haven't swotted up on these constrained intrinsics to review the proposed lowering yet, but added a quick note on the setOperationAction calls. I agree with Luis the test cases would probably be easier to read if using the hard float ABI. I think you're lacking any test coverage for f32 as well.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
214

Should the instances of MVT::i64 be XLenVT?

I also would have imagined it would make sense for these setOperationAction calls to be guarded on hasStdExtF/hasStdExtD appropriately. Is that not the case here?

enhanced and more testcases.

Jim added inline comments.Jun 15 2020, 10:34 PM
llvm/lib/Target/RISCV/RISCVISelLowering.h
212

Don't delete blank line here.

kamleshbhalui marked an inline comment as done.Jun 16 2020, 4:45 AM
kamleshbhalui added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.h
212

ok, will fix it in next update

@asb and @luismarques do you suggest anything here ?

You will need to rebase past D80952, which made constrained fp a target opt-in - though in all honesty, with that patch, this patch is less of a priority as the compiler will not crash any more.

I still don't know how we (the reviewers) should work out whether the lowering of the constrained fp operators is "correct" or not, which is what's holding up this patch anyway.

rebased with the master.

kamleshbhalui marked 4 inline comments as done.Jul 30 2020, 2:29 AM
lenary resigned from this revision.Jan 14 2021, 10:00 AM
rkruppe removed a subscriber: rkruppe.Jan 14 2021, 10:19 AM