diff options
| author | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-12-18 12:35:08 +0000 |
|---|---|---|
| committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2019-12-18 14:41:38 +0000 |
| commit | c3cb089a87b7966900277e4f5cd12355baf3607f (patch) | |
| tree | 0475319db1b612bf1e45d47d3e67e872b7892d79 /llvm/lib/CodeGen | |
| parent | c6a56c9a506e09e03fe4dcf1128799cbfbb6989e (diff) | |
| download | bcm5719-llvm-c3cb089a87b7966900277e4f5cd12355baf3607f.tar.gz bcm5719-llvm-c3cb089a87b7966900277e4f5cd12355baf3607f.zip | |
[gicombiner] Import tryCombineIndexedLoadStore()
Summary:
Now that arbitrary data is supported, import tryCombineIndexedLoadStore()
Depends on D69147
Reviewers: bogner, volkan
Reviewed By: volkan
Subscribers: hiraditya, arphaman, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69151
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp index 6712ff5c732..548e2031543 100644 --- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp @@ -711,18 +711,36 @@ bool CombinerHelper::findPreIndexCandidate(MachineInstr &MI, Register &Addr, } bool CombinerHelper::tryCombineIndexedLoadStore(MachineInstr &MI) { + IndexedLoadStoreMatchInfo MatchInfo; + if (matchCombineIndexedLoadStore(MI, MatchInfo)) { + applyCombineIndexedLoadStore(MI, MatchInfo); + return true; + } + return false; +} + +bool CombinerHelper::matchCombineIndexedLoadStore(MachineInstr &MI, IndexedLoadStoreMatchInfo &MatchInfo) { unsigned Opcode = MI.getOpcode(); if (Opcode != TargetOpcode::G_LOAD && Opcode != TargetOpcode::G_SEXTLOAD && Opcode != TargetOpcode::G_ZEXTLOAD && Opcode != TargetOpcode::G_STORE) return false; - bool IsStore = Opcode == TargetOpcode::G_STORE; - Register Addr, Base, Offset; - bool IsPre = findPreIndexCandidate(MI, Addr, Base, Offset); - if (!IsPre && !findPostIndexCandidate(MI, Addr, Base, Offset)) + MatchInfo.IsPre = findPreIndexCandidate(MI, MatchInfo.Addr, MatchInfo.Base, + MatchInfo.Offset); + if (!MatchInfo.IsPre && + !findPostIndexCandidate(MI, MatchInfo.Addr, MatchInfo.Base, + MatchInfo.Offset)) return false; + return true; +} +void CombinerHelper::applyCombineIndexedLoadStore( + MachineInstr &MI, IndexedLoadStoreMatchInfo &MatchInfo) { + MachineInstr &AddrDef = *MRI.getUniqueVRegDef(MatchInfo.Addr); + MachineIRBuilder MIRBuilder(MI); + unsigned Opcode = MI.getOpcode(); + bool IsStore = Opcode == TargetOpcode::G_STORE; unsigned NewOpcode; switch (Opcode) { case TargetOpcode::G_LOAD: @@ -741,25 +759,22 @@ bool CombinerHelper::tryCombineIndexedLoadStore(MachineInstr &MI) { llvm_unreachable("Unknown load/store opcode"); } - MachineInstr &AddrDef = *MRI.getUniqueVRegDef(Addr); - MachineIRBuilder MIRBuilder(MI); auto MIB = MIRBuilder.buildInstr(NewOpcode); if (IsStore) { - MIB.addDef(Addr); + MIB.addDef(MatchInfo.Addr); MIB.addUse(MI.getOperand(0).getReg()); } else { MIB.addDef(MI.getOperand(0).getReg()); - MIB.addDef(Addr); + MIB.addDef(MatchInfo.Addr); } - MIB.addUse(Base); - MIB.addUse(Offset); - MIB.addImm(IsPre); + MIB.addUse(MatchInfo.Base); + MIB.addUse(MatchInfo.Offset); + MIB.addImm(MatchInfo.IsPre); MI.eraseFromParent(); AddrDef.eraseFromParent(); LLVM_DEBUG(dbgs() << " Combinined to indexed operation"); - return true; } bool CombinerHelper::matchElideBrByInvertingCond(MachineInstr &MI) { |

