[all-commits] [llvm/llvm-project] 4cd2f4: [X86] Coalesce redundant vector register clears in...

Akshay K via All-commits all-commits at lists.llvm.org
Wed Sep 23 02:55:49 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4cd2f4d84b3682908be78bc5cd314507a3d80686
      https://github.com/llvm/llvm-project/commit/4cd2f4d84b3682908be78bc5cd314507a3d80686
  Author: Akshay K <iit.akshay at gmail.com>
  Date:   2026-09-23 (Wed, 23 Sep 2026)

  Changed paths:
    M llvm/lib/Target/X86/X86FrameLowering.cpp
    M llvm/lib/Target/X86/X86InstrInfo.cpp
    M llvm/test/CodeGen/X86/zero-call-used-regs-simd.ll

  Log Message:
  -----------
  [X86] Coalesce redundant vector register clears in zero_call_used_regs (#212147)

This pull request improves how the X86 backend implements
`-fzero-call-used-regs` for vector registers by coalescing aliasing
XMM/YMM/ZMM register views before emitting zeroing instructions. Each
physical vector register is now cleared exactly once, eliminating
redundant clears and avoiding unnecessary `vzeroupper` emission.

Vector register zeroing

- Updated `X86FrameLowering::emitZeroCallUsedRegs` to normalize aliasing
XMM/YMM/ZMM registers to a single representative before emitting clears,
mirroring the existing handling for general-purpose registers.
- Registers XMM0–15 are cleared with VEX-encoded zero idioms, while
XMM16–31 are cleared using EVEX-encoded instructions. Since writes to an
XMM destination also zero the upper bits of the enclosing YMM/ZMM
register, each physical vector register is cleared exactly once.
- Eliminates redundant AVX_SET0/AVX512_512_SET0 pseudos, preventing
unnecessary vzeroupper insertion while preserving the same architectural
zeroization.

AVX512F mask register clearing

- `X86InstrInfo::buildClearRegister` incorrectly gated k0–k7 clearing on
`hasVLX()`. `KSET0W` only requires `AVX512F`, so it fixes mask registers
clearing with `-mattr=+avx512f`.

Tests
- Updated `zero-call-used-regs-simd.ll` to reflect the reduced
instruction sequences across the AVX, AVX2, and AVX-512 code paths.
- Added `all_no_live_vec` to verify that `-fzero-call-used-regs=all`
clears each vector register only once and does not emit a spurious
vzeroupper.

Fixes #191911

Assisted-by: Codex



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