Skip to content

Commit c0377ce

Browse files
[RISCV] Fix SiFive7 formula for Reductions and ordered Reductions
Reductions specified the correct formula in the comments but was implemented incorrectly. Ordered reductions formula was refined to be more accurate to actual hardware. A llvm-mca test case for reductions is added so that we have a better idea of how the model is performing.
1 parent efec733 commit c0377ce

File tree

2 files changed

+674
-3
lines changed

2 files changed

+674
-3
lines changed

llvm/lib/Target/RISCV/RISCVSchedSiFive7.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ class SiFive7GetReductionCycles<string mx, int sew> {
154154
!eq(mx, "MF8") : 1
155155
);
156156
int c = !add(
157-
!div(TwoTimesLMUL, DLEN),
157+
TwoTimesLMUL,
158158
!mul(5, !add(4, !logtwo(!div(DLEN, sew))))
159159
);
160160
}
161161

162-
/// Cycles for ordered reductions take approximatley 5*VL cycles
162+
/// Cycles for ordered reductions take approximatley 6*VL cycles
163163
class SiFive7GetOrderedReductionCycles<string mx, int sew> {
164164
defvar VLEN = 512;
165165
// (VLEN * LMUL) / SEW
@@ -172,7 +172,7 @@ class SiFive7GetOrderedReductionCycles<string mx, int sew> {
172172
!eq(mx, "MF4") : !div(!div(VLEN, 4), sew),
173173
!eq(mx, "MF8") : !div(!div(VLEN, 8), sew),
174174
);
175-
int c = !mul(5, VLUpperBound);
175+
int c = !mul(6, VLUpperBound);
176176
}
177177

178178
class SiFive7AnyToGPRBypass<SchedRead read, int cycles = 2>

0 commit comments

Comments
 (0)