[PATCH] D152365: [AVR] Optimize 8-bit rotation when rotation bits == 3
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 10 17:45:16 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d90f310867: [AVR] Optimize 8-bit rotation when rotation bits == 3 (authored by benshi001).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152365/new/
https://reviews.llvm.org/D152365
Files:
llvm/lib/Target/AVR/AVRISelLowering.cpp
llvm/test/CodeGen/AVR/rotate.ll
Index: llvm/test/CodeGen/AVR/rotate.ll
===================================================================
--- llvm/test/CodeGen/AVR/rotate.ll
+++ llvm/test/CodeGen/AVR/rotate.ll
@@ -15,12 +15,10 @@
define i8 @rotl8_3(i8 %x) {
; CHECK-LABEL: rotl8_3:
; CHECK: ; %bb.0: ; %start
-; CHECK-NEXT: lsl r24
-; CHECK-NEXT: adc r24, r1
-; CHECK-NEXT: lsl r24
-; CHECK-NEXT: adc r24, r1
-; CHECK-NEXT: lsl r24
-; CHECK-NEXT: adc r24, r1
+; CHECK-NEXT: swap r24
+; CHECK-NEXT: bst r24, 0
+; CHECK-NEXT: ror r24
+; CHECK-NEXT: bld r24, 7
; CHECK-NEXT: ret
start:
%0 = call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 3)
@@ -85,15 +83,9 @@
define i8 @rotr8_3(i8 %x) {
; CHECK-LABEL: rotr8_3:
; CHECK: ; %bb.0: ; %start
-; CHECK-NEXT: bst r24, 0
-; CHECK-NEXT: ror r24
-; CHECK-NEXT: bld r24, 7
-; CHECK-NEXT: bst r24, 0
-; CHECK-NEXT: ror r24
-; CHECK-NEXT: bld r24, 7
-; CHECK-NEXT: bst r24, 0
-; CHECK-NEXT: ror r24
-; CHECK-NEXT: bld r24, 7
+; CHECK-NEXT: swap r24
+; CHECK-NEXT: lsl r24
+; CHECK-NEXT: adc r24, r1
; CHECK-NEXT: ret
start:
%0 = call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 3)
Index: llvm/lib/Target/AVR/AVRISelLowering.cpp
===================================================================
--- llvm/lib/Target/AVR/AVRISelLowering.cpp
+++ llvm/lib/Target/AVR/AVRISelLowering.cpp
@@ -427,6 +427,18 @@
Victim = DAG.getNode(AVRISD::ASRBN, dl, VT, Victim,
DAG.getConstant(7, dl, VT));
ShiftAmount = 0;
+ } else if (Op.getOpcode() == ISD::ROTL && ShiftAmount == 3) {
+ // Optimize left rotation 3 bits to swap then right rotation 1 bit.
+ Victim = DAG.getNode(AVRISD::SWAP, dl, VT, Victim);
+ Victim =
+ DAG.getNode(AVRISD::ROR, dl, VT, Victim, DAG.getConstant(1, dl, VT));
+ ShiftAmount = 0;
+ } else if (Op.getOpcode() == ISD::ROTR && ShiftAmount == 3) {
+ // Optimize right rotation 3 bits to swap then left rotation 1 bit.
+ Victim = DAG.getNode(AVRISD::SWAP, dl, VT, Victim);
+ Victim =
+ DAG.getNode(AVRISD::ROL, dl, VT, Victim, DAG.getConstant(1, dl, VT));
+ ShiftAmount = 0;
} else if (Op.getOpcode() == ISD::ROTL && ShiftAmount == 7) {
// Optimize left rotation 7 bits to right rotation 1 bit.
Victim =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152365.530268.patch
Type: text/x-patch
Size: 2324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230611/a1d29383/attachment.bin>
More information about the llvm-commits
mailing list