summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2018-02-21 13:31:35 +0000
committerNicolai Haehnle <nhaehnle@gmail.com>2018-02-21 13:31:35 +0000
commit770397f4cdcfbf2c0e0a9604a4d6065063197317 (patch)
tree8104868ad30833555c235eb51b2c376922d07ef4 /llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
parentd6e1a9404db84990eb428484c28ed978040561ef (diff)
downloadbcm5719-llvm-770397f4cdcfbf2c0e0a9604a4d6065063197317.tar.gz
bcm5719-llvm-770397f4cdcfbf2c0e0a9604a4d6065063197317.zip
AMDGPU: Do not combine loads/store across physreg defs
Summary: Since this pass operates on machine SSA form, this should only really affect M0 in practice. Fixes various piglit variable-indexing/vs-varying-array-mat4-index-* Change-Id: Ib2a1dc3a8d7b08225a8da49a86f533faa0986aa8 Fixes: r317751 ("AMDGPU: Merge S_BUFFER_LOAD_DWORD_IMM into x2, x4") Reviewers: arsenm, mareko, rampitec Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits Differential Revision: https://reviews.llvm.org/D40343 llvm-svn: 325677
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
index 6f7ae78ba52..72d6f4d645d 100644
--- a/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
@@ -228,6 +228,16 @@ canMoveInstsAcrossMemOp(MachineInstr &MemOp,
return true;
}
+static bool
+hasPhysRegDef(MachineInstr &MI) {
+ for (const MachineOperand &Def : MI.defs()) {
+ if (Def.isReg() &&
+ TargetRegisterInfo::isPhysicalRegister(Def.getReg()))
+ return true;
+ }
+ return false;
+}
+
bool SILoadStoreOptimizer::offsetsCanBeCombined(CombineInfo &CI) {
// XXX - Would the same offset be OK? Is there any reason this would happen or
// be useful?
@@ -350,6 +360,13 @@ bool SILoadStoreOptimizer::findMatchingInst(CombineInfo &CI) {
return false;
}
+ if (hasPhysRegDef(*MBBI)) {
+ // We could re-order this instruction in theory, but it would require
+ // tracking physreg defs and uses. This should only affect M0 in
+ // practice.
+ return false;
+ }
+
if (MBBI->mayLoadOrStore() &&
(!memAccessesCanBeReordered(*CI.I, *MBBI, TII, AA) ||
!canMoveInstsAcrossMemOp(*MBBI, CI.InstsToMove, TII, AA))) {
@@ -437,7 +454,8 @@ bool SILoadStoreOptimizer::findMatchingInst(CombineInfo &CI) {
// down past this instruction.
// check if we can move I across MBBI and if we can move all I's users
if (!memAccessesCanBeReordered(*CI.I, *MBBI, TII, AA) ||
- !canMoveInstsAcrossMemOp(*MBBI, CI.InstsToMove, TII, AA))
+ !canMoveInstsAcrossMemOp(*MBBI, CI.InstsToMove, TII, AA) ||
+ hasPhysRegDef(*MBBI))
break;
}
return false;
OpenPOWER on IntegriCloud