[all-commits] [llvm/llvm-project] 58eaa3: AMDGPU: Fold inline immediates in peephole-opt

Matt Arsenault via All-commits all-commits at lists.llvm.org
Thu Jul 9 03:58:53 PDT 2026


  Branch: refs/heads/users/arsenm/amdgpu/fold-inline-imm-peephole-opt
  Home:   https://github.com/llvm/llvm-project
  Commit: 58eaa33aeed68a10a45a82719dcba23605225628
      https://github.com/llvm/llvm-project/commit/58eaa33aeed68a10a45a82719dcba23605225628
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
    M llvm/test/CodeGen/AMDGPU/optimize-compare.mir
    M llvm/test/CodeGen/AMDGPU/peephole-fold-imm.mir
    M llvm/test/CodeGen/AMDGPU/sdiv64.ll

  Log Message:
  -----------
  AMDGPU: Fold inline immediates in peephole-opt

Currently the AMDGPU implementation of foldImmediate handles a small
set of special cases that require rewriting the instruction opcode
(COPY -> mov, and fma-like to fmac-like). Most general immediate folding
is handled in SIFoldOperands. Teach PeepholeOpt to fold all inline
immediates into target instructions which should always be an improvement.

This is to help alleviate some phase ordering problems in future changes.
I've also never liked how SIFoldOperands is written and it could use a
rewrite, and this will alleviate some of its responsibilties. It will
always be necessary since some operand folds require additional context
that foldImmediate won't have (namely, we have to make contextually aware
tradeoffs for which operands are worth folding to respect constant bus
restrictions, considering other users of the values).

Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>



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