Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Improve codegen for i8/i16 'atomicrmw xchg a, {0,-1}'
As noted in <llvm#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 llvm#64090 Differential Revision: https://reviews.llvm.org/D156801
- Loading branch information