[llvm] bf13a71 - AMDGPU/SILoadStoreOptimizer: Simplify function
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 06:53:21 PST 2019
Author: Tom Stellard
Date: 2019-12-12T06:53:03-08:00
New Revision: bf13a71095fd95897cca032e194d73b88af22dea
URL: https://github.com/llvm/llvm-project/commit/bf13a71095fd95897cca032e194d73b88af22dea
DIFF: https://github.com/llvm/llvm-project/commit/bf13a71095fd95897cca032e194d73b88af22dea.diff
LOG: AMDGPU/SILoadStoreOptimizer: Simplify function
Reviewers: arsenm, nhaehnle
Reviewed By: arsenm
Subscribers: merge_guards_bot, kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71044
Added:
Modified:
llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
index 1d64bf892ed2..d584b868bb5c 100644
--- a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
@@ -2006,80 +2006,68 @@ SILoadStoreOptimizer::optimizeInstsWithSameBaseAddr(
for (auto I = MergeList.begin(); I != MergeList.end(); ++I) {
CombineInfo &CI = *I;
+ if (CI.InstClass == UNKNOWN)
+ continue;
+
+ if (!findMatchingInst(CI))
+ goto done;
+
+ Modified = true;
+ removeCombinedInst(MergeList, *CI.Paired);
+
switch (CI.InstClass) {
default:
+ llvm_unreachable("unknown InstClass");
break;
- case DS_READ:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeRead2Pair(CI);
- CI.setMI(NewMI, *TII, *STM);
- }
+ case DS_READ: {
+ MachineBasicBlock::iterator NewMI = mergeRead2Pair(CI);
+ CI.setMI(NewMI, *TII, *STM);
break;
- case DS_WRITE:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeWrite2Pair(CI);
- CI.setMI(NewMI, *TII, *STM);
- }
+ }
+ case DS_WRITE: {
+ MachineBasicBlock::iterator NewMI = mergeWrite2Pair(CI);
+ CI.setMI(NewMI, *TII, *STM);
break;
- case S_BUFFER_LOAD_IMM:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeSBufferLoadImmPair(CI);
- CI.setMI(NewMI, *TII, *STM);
- OptimizeListAgain |= (CI.Width0 + CI.Width1) < 16;
- }
+ }
+ case S_BUFFER_LOAD_IMM: {
+ MachineBasicBlock::iterator NewMI = mergeSBufferLoadImmPair(CI);
+ CI.setMI(NewMI, *TII, *STM);
+ OptimizeListAgain |= (CI.Width0 + CI.Width1) < 16;
break;
- case BUFFER_LOAD:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeBufferLoadPair(CI);
- CI.setMI(NewMI, *TII, *STM);
- OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
- }
+ }
+ case BUFFER_LOAD: {
+ MachineBasicBlock::iterator NewMI = mergeBufferLoadPair(CI);
+ CI.setMI(NewMI, *TII, *STM);
+ OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
break;
- case BUFFER_STORE:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeBufferStorePair(CI);
- CI.setMI(NewMI, *TII, *STM);
- OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
- }
+ }
+ case BUFFER_STORE: {
+ MachineBasicBlock::iterator NewMI = mergeBufferStorePair(CI);
+ CI.setMI(NewMI, *TII, *STM);
+ OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
break;
- case MIMG:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeImagePair(CI);
- CI.setMI(NewMI, *TII, *STM);
- OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
- }
+ }
+ case MIMG: {
+ MachineBasicBlock::iterator NewMI = mergeImagePair(CI);
+ CI.setMI(NewMI, *TII, *STM);
+ OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
break;
- case TBUFFER_LOAD:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeTBufferLoadPair(CI);
- CI.setMI(NewMI, *TII, *STM);
- OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
- }
+ }
+ case TBUFFER_LOAD: {
+ MachineBasicBlock::iterator NewMI = mergeTBufferLoadPair(CI);
+ CI.setMI(NewMI, *TII, *STM);
+ OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
break;
- case TBUFFER_STORE:
- if (findMatchingInst(CI)) {
- Modified = true;
- removeCombinedInst(MergeList, *CI.Paired);
- MachineBasicBlock::iterator NewMI = mergeTBufferStorePair(CI);
- CI.setMI(NewMI, *TII, *STM);
- OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
- }
+ }
+ case TBUFFER_STORE: {
+ MachineBasicBlock::iterator NewMI = mergeTBufferStorePair(CI);
+ CI.setMI(NewMI, *TII, *STM);
+ OptimizeListAgain |= (CI.Width0 + CI.Width1) < 4;
break;
}
+ }
+
+done:
// Clear the InstsToMove after we have finished searching so we don't have
// stale values left over if we search for this CI again in another pass
// over the block.
More information about the llvm-commits
mailing list