Skip to content

Commit ec350d8

Browse files
committed
Optimize sla a to add a,a.
1 parent 42e37b5 commit ec350d8

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

llvm/lib/Target/Z80/Z80InstrInfo.td

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,11 @@ multiclass UnOp8RF<OtherPrefix prefix, bits<8> opcode, string mnemonic,
716716
list<Predicate> Preds = []> {
717717
defvar s = !cond(!eq(prefix, NoPre): "r", !eq(prefix, CBPre): "g");
718718
defvar rc8 = !cond(!eq(prefix, NoPre): R8, !eq(prefix, CBPre): G8);
719-
def 8#s : I <Pre<Idx0Pre, prefix>, opcode, mnemonic, "\t$dst", "$imp = $dst",
720-
(outs rc8:$dst), (ins rc8:$imp),
721-
[(set rc8:$dst, F,
722-
(!cast<SDNode>(!strconcat("Z80", mnemonic, "_flag"))
723-
rc8:$imp))]>,
719+
def 8#s : I<Pre<Idx0Pre, prefix>, opcode, mnemonic, "\t$dst", "$imp = $dst",
720+
(outs rc8:$dst), (ins rc8:$imp),
721+
[(set rc8:$dst, F,
722+
(!cast<SDNode>(!strconcat("Z80", mnemonic, "_flag"))
723+
rc8:$imp))]>,
724724
Requires<Preds>;
725725
let mayLoad = true, mayStore = true in {
726726
def 8p : I <Pre<Idx0Pre, prefix>, opcode, mnemonic, "\t$adr", "",
@@ -746,11 +746,11 @@ multiclass UnOp8RFF<OtherPrefix prefix, bits<8> opcode, string mnemonic,
746746
list<Predicate> Preds = []> {
747747
defvar s = !cond(!eq(prefix, NoPre): "r", !eq(prefix, CBPre): "g");
748748
defvar rc8 = !cond(!eq(prefix, NoPre): R8, !eq(prefix, CBPre): G8);
749-
def 8#s : I <Pre<Idx0Pre, prefix>, opcode, mnemonic, "\t$dst", "$imp = $dst",
750-
(outs rc8:$dst), (ins rc8:$imp),
751-
[(set rc8:$dst, F,
752-
(!cast<SDNode>(!strconcat("Z80", mnemonic, "_flag"))
753-
rc8:$imp, F))]>,
749+
def 8#s : I<Pre<Idx0Pre, prefix>, opcode, mnemonic, "\t$dst", "$imp = $dst",
750+
(outs rc8:$dst), (ins rc8:$imp),
751+
[(set rc8:$dst, F,
752+
(!cast<SDNode>(!strconcat("Z80", mnemonic, "_flag"))
753+
rc8:$imp, F))]>,
754754
Requires<Preds>;
755755
let mayLoad = true, mayStore = true in {
756756
def 8p : I <Pre<Idx0Pre, prefix>, opcode, mnemonic, "\t$adr", "",

llvm/lib/Target/Z80/Z80MachineLateOptimization.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,17 @@ bool Z80MachineLateOptimization::runOnMachineFunction(MachineFunction &MF) {
564564
MIB.addReg(DstReg, RegState::Implicit | RegState::Undef);
565565
MIB.addReg(Z80::F, RegState::Implicit | getKillRegState(reuse(Z80::F)));
566566
break;
567+
case Z80::SLA8g:
568+
if (DstReg != Z80::A || !LiveUnits.available(Z80::F))
569+
break;
570+
LLVM_DEBUG(dbgs() << "Replacing: "; MIB->dump();
571+
dbgs() << " With: ");
572+
MIB->setDesc(TII.get(Z80::ADD8ar));
573+
MIB->untieRegOperand(1);
574+
MIB->getOperand(0).setImplicit();
575+
MIB->getOperand(1).setImplicit();
576+
MIB.addReg(DstReg, getKillRegState(MIB->getOperand(1).isKill()));
577+
break;
567578
case Z80::RLC8g:
568579
case Z80::RRC8g:
569580
case Z80:: RL8g:

0 commit comments

Comments
 (0)