[all-commits] [llvm/llvm-project] be0dac: [RISCV] Improve codegen for i8/i16 'atomicrmw xchg...

Alex Bradbury via All-commits all-commits at lists.llvm.org
Wed Aug 2 01:50:01 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be0dac268db7f426c26a3cc16f5fbdf96c6cd9e1
      https://github.com/llvm/llvm-project/commit/be0dac268db7f426c26a3cc16f5fbdf96c6cd9e1
  Author: Alex Bradbury <asb at igalia.com>
  Date:   2023-08-02 (Wed, 02 Aug 2023)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/atomic-rmw.ll

  Log Message:
  -----------
  [RISCV] Improve codegen for i8/i16 'atomicrmw xchg a, {0,-1}'

As noted in <https://github.com/llvm/llvm-project/issues/64090>, it's
more efficient to lower a partword 'atomicrmw xchg a, 0` to and amoand
with appropriate mask. There are a range of possible ways to go about
this - e.g. writing a combine based on the
`llvm.riscv.masked.atomicrmw.xchg` intrinsic, or introducing a new
interface to AtomicExpandPass to allow target-specific atomics
conversions, or trying to lift the conversion into AtomicExpandPass
itself based on querying some target hook. Ultimately I've gone with
what appears to be the simplest approach - just covering this case in
emitMaskedAtomicRMWIntrinsic. I perhaps should have given that hook a
different name way back when it was introduced.

This also handles the `atomicrmw xchg a, -1` case suggested by Craig
during review.

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

Differential Revision: https://reviews.llvm.org/D156801




More information about the All-commits mailing list