[PATCH] D117725: [AVR] Fix atomicrmw result value

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 19 14:44:17 PST 2022


aykevl created this revision.
aykevl added reviewers: dylanmckay, benshi001.
Herald added subscribers: Jim, hiraditya.
aykevl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch fixes the atomicrmw result value to be the value before the operation instead of the value after the operation. This was a bug, left as a FIXME in the code (see D97127 <https://reviews.llvm.org/D97127>).

>From the LangRef:

> The contents of memory at the location specified by the `‘<pointer>’` operand are atomically read, modified, and written back. The original value at the location is returned.

Doing this expansion early allows the register allocator to arrange registers in such a way that commutable operations are simply swapped around as needed, which results in shorter code while still being correct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117725

Files:
  llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
  llvm/lib/Target/AVR/AVRISelLowering.cpp
  llvm/lib/Target/AVR/AVRISelLowering.h
  llvm/lib/Target/AVR/AVRInstrInfo.td
  llvm/test/CodeGen/AVR/atomics/load16.ll
  llvm/test/CodeGen/AVR/atomics/load8.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117725.401411.patch
Type: text/x-patch
Size: 17309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220119/728f3f04/attachment.bin>


More information about the llvm-commits mailing list