[llvm-mca][RISC-V] Remove duplicated use of SP from `c.addi4spn` (#189980) `c.addi4spn` instruction implicitly uses the X2 (SP) register, but in addition to being present in the Uses list, it is also modeled as an explicit operand with the SP register class. This duplication causes missed bypasses in llvm-mca when the instruction needs to read the SP value written by a previous instruction. For example, on a `sifive-u74` CPU, the following timeline excerpt shows that the `c.addi4spn` is issues 2 cycles later than expected by the GPR bypass: ``` Timeline view: Index 012345678 [0,0] DeeE . . mv sp, a0 [0,1] . DeeE . addi a1, sp, 12 ``` This patch removes SP from the Uses list, relying solely on the explicit SP operand (as in `c.addi16sp`), which restores the expected bypass behavior. A test is added that checks the same scenario for `c.addi16sp` as well, since a similar issue may also occur there.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.