mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
8ded1a7aa8
This patch fixes some issues with the RORB pseudo instruction. - A minor issue in which the instructions were said to use the SREG, which is not true. - An issue with the BLD instruction, which did not have an output operand. - A major issue in which invalid instructions were generated. The fix also reduce RORB from 4 to 3 instructions, so it's also a small optimization. These issues were flagged by the machine verifier. Differential Revision: https://reviews.llvm.org/D96957
59 lines
1.0 KiB
LLVM
59 lines
1.0 KiB
LLVM
; RUN: llc < %s -march=avr | FileCheck %s
|
|
|
|
; Bit rotation tests.
|
|
|
|
; CHECK-LABEL: rol8:
|
|
define i8 @rol8(i8 %val, i8 %amt) {
|
|
; CHECK: andi r22, 7
|
|
|
|
; CHECK-NEXT: dec r22
|
|
; CHECK-NEXT: brmi .LBB0_2
|
|
|
|
; CHECK-NEXT: .LBB0_1:
|
|
; CHECK-NEXT: lsl r24
|
|
; CHECK-NEXT: adc r24, r1
|
|
; CHECK-NEXT: dec r22
|
|
; CHECK-NEXT: brpl .LBB0_1
|
|
|
|
; CHECK-NEXT: .LBB0_2:
|
|
; CHECK-NEXT: ret
|
|
%mod = urem i8 %amt, 8
|
|
|
|
%inv = sub i8 8, %mod
|
|
%parta = shl i8 %val, %mod
|
|
%partb = lshr i8 %val, %inv
|
|
|
|
%rotl = or i8 %parta, %partb
|
|
|
|
ret i8 %rotl
|
|
}
|
|
|
|
|
|
; CHECK-LABEL: ror8:
|
|
define i8 @ror8(i8 %val, i8 %amt) {
|
|
; CHECK: andi r22, 7
|
|
|
|
; CHECK-NEXT: dec r22
|
|
; CHECK-NEXT: brmi .LBB1_2
|
|
|
|
; CHECK-NEXT: .LBB1_1:
|
|
; CHECK-NEXT: bst r24, 0
|
|
; CHECK-NEXT: ror r24
|
|
; CHECK-NEXT: bld r24, 7
|
|
; CHECK-NEXT: dec r22
|
|
; CHECK-NEXT: brpl .LBB1_1
|
|
|
|
; CHECK-NEXT: .LBB1_2:
|
|
; CHECK-NEXT: ret
|
|
%mod = urem i8 %amt, 8
|
|
|
|
%inv = sub i8 8, %mod
|
|
%parta = lshr i8 %val, %mod
|
|
%partb = shl i8 %val, %inv
|
|
|
|
%rotr = or i8 %parta, %partb
|
|
|
|
ret i8 %rotr
|
|
}
|
|
|