Page MenuHomePhabricator

[RISCV] Add support for lowering jumptables
Needs ReviewPublic

Authored by asb on Jun 21 2018, 7:02 AM.

Details

Summary

Previously, the generation of jumptables was disabled. This patch adds the necessary support, as reflected in the updated output in test/CodeGen/RISCV/jumptable.ll.

Diff Detail

Event Timeline

asb created this revision.Jun 21 2018, 7:02 AM
sabuasal edited reviewers, added: sabuasal; removed: sameer.abuasal.Jun 27 2018, 2:50 PM
apazos added inline comments.Jun 27 2018, 6:01 PM
lib/Target/RISCV/RISCVISelLowering.cpp
153

Alex, I see lower performance when creating jump tables. We might need to set a minimum JT entries value to avoid the degradation.

GCC using 5 as threshold to decide using jump table or not for RISC-V and LLVM using 4.

Reference:
GCC: https://github.com/gcc-mirror/gcc/blob/master/gcc/targhooks.c#L1628

  • Note: targetm.have_casesi () return false for RISC-V.

LLVM: https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/TargetLoweringBase.cpp#L72

jrtc27 added a subscriber: jrtc27.Dec 7 2018, 8:56 AM
lenary added a subscriber: lenary.Jul 31 2019, 8:57 AM

Alex, we have not yet merged this patch. We should merge it and we can leave the default as GCC.
This makes our code size gap with GCC smaller.
In the past I did see degradation in some SiFive hardware (I think it was on HiFive1 board). Maybe some of the SiFive colleagues can look at it at some point.

lenary added inline comments.Mar 18 2020, 8:18 AM
lib/Target/RISCV/RISCVISelLowering.cpp
375

I'm not sure we should merge this without support for position independent code.

It looks like it needs more work indeed. Enabling it won't build compiler-rt.