This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Increase scalar integer divide latency for SiFive7.
ClosedPublic

Authored by craig.topper on May 22 2023, 12:30 PM.

Details

Summary

The scalar divider produces 1 bit per cycle so the worst case
latency is the input width plus a couple cycles.

Diff Detail

Event Timeline

craig.topper created this revision.May 22 2023, 12:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 12:30 PM
craig.topper requested review of this revision.May 22 2023, 12:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 12:30 PM
llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
201–202

1 bit per cycle so the worst case latency is the input width plus a couple cycles.

Why does latency take 2 extra cycles and resource cycles is only 1 extra cycle?

craig.topper added inline comments.May 22 2023, 12:55 PM
llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
201–202

I might still have the numbers off by a couple cycles, but it's probably better than being off by a factor of 2 or 4. They were already 1 apart so I left them 1 apart. This is what's currently in our downstream.

The basic idea is that there is one pipeline stage in the divider that is used repeatedly in a loop. There is 1-2 stages in front of that and 1-2 stages after that. Two divides can't overlap in the repeated part but we might be able to start a new divide while the previous divide is still in the stages after the repeated part. The ResourceCycles for SiFive7IDiv is intended to track the number of cycles that can't overlap. Unfortunately, I don't have the exact number for how much they can overlap.

This revision is now accepted and ready to land.May 22 2023, 1:02 PM
This revision was landed with ongoing or failed builds.May 22 2023, 1:37 PM
This revision was automatically updated to reflect the committed changes.