[all-commits] [llvm/llvm-project] 0bb4a6: [RISCV] Don't move memory instructions across call...

Pengcheng Wang via All-commits all-commits at lists.llvm.org
Tue Jul 28 23:30:26 PDT 2026


  Branch: refs/heads/release/23.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 0bb4a649970777b8dbd66cd2aae3f66f6b8f1359
      https://github.com/llvm/llvm-project/commit/0bb4a649970777b8dbd66cd2aae3f66f6b8f1359
  Author: Pengcheng Wang <wangpengcheng.pp at bytedance.com>
  Date:   2026-07-29 (Wed, 29 Jul 2026)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
    M llvm/test/CodeGen/RISCV/rvv/vmerge-peephole.mir

  Log Message:
  -----------
  [RISCV] Don't move memory instructions across calls in isSafeToMove (#212236)

RISCVInstrInfo::isSafeToMove scans the instructions between From and To
to decide whether a memory instruction can be moved, but it only treated
mayStore() instructions as barriers. Calls on RISC-V are modeled with
isCall() and a register mask rather than mayStore(), so a load could be
moved across a call even though the callee may clobber the loaded
memory.

RISCVVectorPeephole::foldVMergeToMask uses this helper via ensureDominates()
to sink a load into a masked load when folding it into a vmerge, which
produced wrong code when the load was sunk past a call.

Instead of hand-rolling the barrier check, call MachineInstr::isSafeToMove
on each intervening instruction to populate SawStore. That is the same
helper used on From below, and it already treats calls (as well as PHIs
and ordered memory references) as stores.

This fixes #212226.

Assisted-by: TRAE CLI (DeepSeek V4 Pro)
(cherry picked from commit 840060f2f85c2d3f8ebe1c9304770d682e4141f6)



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