[PATCH] D128588: [AVR] Fix expanding MOVW for overlapping registers
Patryk Wychowaniec via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 25 10:24:32 PDT 2022
Patryk27 created this revision.
Herald added subscribers: Jim, JDevlieghere, hiraditya, dylanmckay.
Herald added a project: All.
Patryk27 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Sometimes the codegen emits a `COPY` with overlapping registers, such as
this one:
$r25r24 = COPY $r24r23
Our current expansion of such `COPY` would be wrong, since it'd start
with the lower register first, with the second `mov` assuming the
registers are not modified in-between:
mov r24, r23
mov r25, r24
(i.e. that's effectively `mov r25, r23`, which is _ayy ayy bad_.)
This patch improves the expansion by making it detect whether the
registers are overlapping and if so, expanding from the high register
first:
mov r25, r24
mov r24, r23
Because our registers are always paired in descending order (e.g.
there's r25r24, but no r24r25), I think it'd be safe to go with the
high-to-low expansion always (not only if the registers overlap), but
that makes the output a bit more difficult to follow and would require
adjusting the existing tests -- so I went with the more safer & simpler
route.
In the wild, this was found here:
https://github.com/rust-lang/rust/issues/98167.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D128588
Files:
llvm/lib/Target/AVR/AVRInstrInfo.cpp
llvm/test/CodeGen/AVR/pseudo/COPY.mir
llvm/test/CodeGen/AVR/rust-bug-98167.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128588.439996.patch
Type: text/x-patch
Size: 4251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220625/54935258/attachment.bin>
More information about the llvm-commits
mailing list