[all-commits] [llvm/llvm-project] 77a451: [AArch64] Fold UMOV(lane 0) + GPR store in FPR sto...

Kunal Pathak via All-commits all-commits at lists.llvm.org
Thu Jun 4 10:25:33 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 77a4516f18785307d3a3add49de0aa151a69fdcf
      https://github.com/llvm/llvm-project/commit/77a4516f18785307d3a3add49de0aa151a69fdcf
  Author: Kunal Pathak <kunalspathak.github at gmail.com>
  Date:   2026-06-04 (Thu, 04 Jun 2026)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
    A llvm/test/CodeGen/AArch64/ldst-opt-umov-fpr-store.mir
    A llvm/test/CodeGen/AArch64/umov-fpr-store-from-phi.ll

  Log Message:
  -----------
  [AArch64] Fold UMOV(lane 0) + GPR store in FPR store (#199139)

Problem: LLVM generates `umov w8, v0.h[0]` + `strh w8, [x0]` instead of
`str h0, [x0]` when storing vector lane 0 to memory, specifically when
SimplifyCFG merges stores across branches -- splitting the
extractelement and store into different basic blocks and preventing the
existing DAG combine from firing.

https://godbolt.org/z/v5G9ohMPa

Root cause: SimplifyCFG creates a PHI + merged store in a successor
block. SelectionDAG ISel processes each block independently, so it
lowers the extract to `UMOV` (GPR) in the predecessor and the store sees
only a GPR value via the PHI. Late tail duplication puts the store back
in the same block, but the `UMOV` is already baked in.

Fix: Added a post-RA peephole in `AArch64LoadStoreOptimizer` (step 6 in
`optimizeBlock`) that recognizes `UMOVvi*_idx0` + GPR store patterns and
replaces them with direct FPR sub-register stores. The peephole:
- Handles all element sizes: i8 (`bsub`), i16 (`hsub`), i32 (`ssub`),
i64 (`dsub`)
- Correctly updates liveness by clearing intervening kill flags on the
vector register
- Bails out if the GPR value has other uses, the vector register is
clobbered, or the store doesn't kill the GPR

Assisted-by: Claude

Fixes: https://github.com/llvm/llvm-project/issues/137086

---------

Co-authored-by: Kunal Pathak <kupathak at fb.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