llvm / llvm/llvm-project

[RISC-V] Missed Opportunity for MULHR variants

Open
#180,970 8 comments 0 reactions 1 assignee Claimed by @topperc View on GitHub
backend:RISC-V missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

There is a typical C code pattern, that can be implemented as a MULHR instruction.

https://godbolt.org/z/nhEje8qdc

Currently, the P extension is used for this, but only by using the widening multiplication.
The whole thing should be equivalent to a rounding MULH.

This is a common code sequence in NNs.
CMSIS-NN calls this function nn_doubling_high_mult_no_sat.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.