llvm-project/llvm/test/CodeGen/AVR/rust-bug-98167.ll
Patryk Wychowaniec 5650688e72 [AVR] Fix expanding MOVW for overlapping registers
When expanding a MOVW (16-bit copy) to two MOVs (8-bit copy), the
lower byte always comes first. This is incorrect for corner cases like
'$r24r23 -> $r25r24', in which the higher byte copy should come first.

Current patch fixes that bug as recorded at
https://github.com/rust-lang/rust/issues/98167

Reviewed By: benshi001

Differential Revision: https://reviews.llvm.org/D128588
2022-06-26 17:20:07 +08:00

23 lines
575 B
LLVM

; RUN: llc < %s -march=avr | FileCheck %s
; The bug can be found here:
; https://github.com/rust-lang/rust/issues/98167
;
; In this test, `extractvalue` + `call` generate a copy with overlapping
; registers (`$r25r24 = COPY $r24r23`) that used to be expanded incorrectly.
define void @main() {
; CHECK-LABEL: main:
; CHECK: rcall foo
; CHECK-NEXT: mov r25, r24
; CHECK-NEXT: mov r24, r23
; CHECK-NEXT: rcall bar
%1 = call { i8, i16 } @foo()
%2 = extractvalue { i8, i16 } %1, 1
call void @bar(i16 %2)
ret void
}
declare { i8, i16 } @foo()
declare void @bar(i16 %0)