[llvm] [RISCV][TII] Add and use new hook to optimize/canonicalize instructions after MachineCopyPropagation (PR #137973)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 1 08:20:23 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- llvm/include/llvm/CodeGen/TargetInstrInfo.h llvm/lib/CodeGen/MachineCopyPropagation.cpp llvm/lib/Target/RISCV/RISCVInstrInfo.cpp llvm/lib/Target/RISCV/RISCVInstrInfo.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index da5e4086a..50bb7f62a 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -3990,7 +3990,8 @@ bool RISCVInstrInfo::optimizeInstruction(MachineInstr &MI) const {
// and rd, zero, rs => addi rd, zero, 0
// mul* rd, rs, zero => addi rd, zero, 0
// mul* rd, zero, rs => addi rd, zero, 0
- if (MI.getOperand(1).getReg() == RISCV::X0 || MI.getOperand(2).getReg() == RISCV::X0) {
+ if (MI.getOperand(1).getReg() == RISCV::X0 ||
+ MI.getOperand(2).getReg() == RISCV::X0) {
MI.getOperand(1).setReg(RISCV::X0);
MI.getOperand(2).ChangeToImmediate(0);
MI.setDesc(get(RISCV::ADDI));
``````````
</details>
https://github.com/llvm/llvm-project/pull/137973
More information about the llvm-commits
mailing list