[all-commits] [llvm/llvm-project] 52b345: [RISCV][TII] Add and use new hook to simplify/cano...

Alex Bradbury via All-commits all-commits at lists.llvm.org
Thu May 8 04:33:36 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 52b345d036677e6377ea5e2022a1b6bd403ed91e
      https://github.com/llvm/llvm-project/commit/52b345d036677e6377ea5e2022a1b6bd403ed91e
  Author: Alex Bradbury <asb at igalia.com>
  Date:   2025-05-08 (Thu, 08 May 2025)

  Changed paths:
    M llvm/include/llvm/CodeGen/TargetInstrInfo.h
    M llvm/lib/CodeGen/MachineCopyPropagation.cpp
    M llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
    M llvm/lib/Target/RISCV/RISCVInstrInfo.h
    M llvm/test/CodeGen/RISCV/machine-copyprop-simplifyinstruction.mir

  Log Message:
  -----------
  [RISCV][TII] Add and use new hook to simplify/canonicalize instructions after MachineCopyPropagation (#137973)

PR #136875 was posted as a draft PR that handled a subset of these
cases, using the CompressPat mechanism. The consensus from that
discussion (and a conclusion I agree with) is that it would be
beneficial doing this optimisation earlier on, and in a way that isn't
limited just to cases that can be handled by instruction compression.

The most common source for instructions that can be
optimized/canonicalized in this way is through tail duplication in
MachineBlockPlacement followed by machine copy propagation. For RISC-V,
choosing a more canonical instruction allows it to be compressed when it
couldn't be before. There is the potential that it would make other
MI-level optimisations easier.

This modifies ~910 instructions across an llvm-test-suite build
including SPEC2017, targeting rva22u64. Looking at the diff, it seems
there's room for eliminating instructions or further propagating after
this.

Coverage of instructions is based on observations from a script written
to find redundant or improperly canonicalized instructions (though I aim
to support all instructions in a 'group' at once, e.g. MUL* even if I
only saw some variants of MUL in practice).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list