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

Matt Arsenault via All-commits all-commits at lists.llvm.org
Tue Jul 21 09:29:46 PDT 2026


  Branch: refs/heads/users/arsenm/amdgpu/fold-inline-imm-peephole-opt
  Home:   https://github.com/llvm/llvm-project
  Commit: 306874cb89e21154c4d7065e4a1e8619f4993dd1
      https://github.com/llvm/llvm-project/commit/306874cb89e21154c4d7065e4a1e8619f4993dd1
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-07-21 (Tue, 21 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>


  Commit: 5c571278b8c93dde90908b11f879f31eb9d9031c
      https://github.com/llvm/llvm-project/commit/5c571278b8c93dde90908b11f879f31eb9d9031c
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-07-21 (Tue, 21 Jul 2026)

  Changed paths:
    M llvm/test/CodeGen/AMDGPU/peephole-fold-imm.mir

  Log Message:
  -----------
  add bad pseudo_scalar_trans_restriction test


Compare: https://github.com/llvm/llvm-project/compare/58eaa33aeed6...5c571278b8c9

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