summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorQuentin Colombet <quentin.colombet@gmail.com>2019-03-27 17:27:56 +0000
committerQuentin Colombet <quentin.colombet@gmail.com>2019-03-27 17:27:56 +0000
commit89daf49e5c56a7e4b3bc72fad64be53139912670 (patch)
tree4d21223d7bc7b36579cc94a4262e27f7c503500c /llvm
parente1eab42f65f2d5479bbefaaa967e66746b94a003 (diff)
downloadbcm5719-llvm-89daf49e5c56a7e4b3bc72fad64be53139912670.tar.gz
bcm5719-llvm-89daf49e5c56a7e4b3bc72fad64be53139912670.zip
[PeepholeOpt] Don't stop simplifying copies on sequence of subregs
This patch removes an overly conservative check that would prevent simplifying copies when the value we were tracking would go through several subregister indices. Indeed, the intend of this check was to not track values whenever we have to compose subregister, but actually what the check was doing was bailing anytime we see a second subreg, even if that second subreg would actually be the new source of truth (as opposed to a part of that subreg). Differential Revision: https://reviews.llvm.org/D59891 llvm-svn: 357095
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/PeepholeOptimizer.cpp7
-rw-r--r--llvm/test/CodeGen/AMDGPU/peephole-opt-regseq-removal.mir34
2 files changed, 35 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
index f5277490ae6..2307e9972ec 100644
--- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -1900,13 +1900,8 @@ ValueTrackerResult ValueTracker::getNextSourceFromRegSequence() {
// Def = REG_SEQUENCE v0, sub0, v1, sub1, ...
// Check if one of the operand defines the subreg we are interested in.
for (const RegSubRegPairAndIdx &RegSeqInput : RegSeqInputRegs) {
- if (RegSeqInput.SubIdx == DefSubReg) {
- if (RegSeqInput.SubReg)
- // Bail if we have to compose sub registers.
- return ValueTrackerResult();
-
+ if (RegSeqInput.SubIdx == DefSubReg)
return ValueTrackerResult(RegSeqInput.Reg, RegSeqInput.SubReg);
- }
}
// If the subreg we are tracking is super-defined by another subreg,
diff --git a/llvm/test/CodeGen/AMDGPU/peephole-opt-regseq-removal.mir b/llvm/test/CodeGen/AMDGPU/peephole-opt-regseq-removal.mir
new file mode 100644
index 00000000000..c3c0758f1a8
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/peephole-opt-regseq-removal.mir
@@ -0,0 +1,34 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=amdgcn -run-pass peephole-opt -verify-machineinstrs -o - %s | FileCheck -check-prefix=GCN %s
+
+# Check that when we jump through several subregisters in sequence of
+# reg_sequence we can still find a plain src for a copy.
+# In this specific test, we want %4 to read directly from %1 and
+# %5 from %0. These values come from the respective chains:
+# %4 -> %3.sub0 -> %2.sub1 -> %1
+# %5 -> %3.sub1 -> %2.sub0 -> %0
+#
+# We used to not simplify this because we were bailing when two
+# subreg indices were in the same chain (%3.subX and %2.subY)
+---
+name: reg_sequence_removal
+body: |
+ bb.0:
+ liveins: $vgpr0, $vgpr1
+
+ ; GCN-LABEL: name: reg_sequence_removal
+ ; GCN: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+ ; GCN: [[COPY1:%[0-9]+]]:vgpr_32 = COPY $vgpr1
+ ; GCN: [[REG_SEQUENCE:%[0-9]+]]:vreg_64 = REG_SEQUENCE [[COPY]], %subreg.sub0, [[COPY1]], %subreg.sub1
+ ; GCN: [[REG_SEQUENCE1:%[0-9]+]]:vreg_64 = REG_SEQUENCE [[REG_SEQUENCE]].sub1, %subreg.sub0, [[REG_SEQUENCE]].sub0, %subreg.sub1
+ ; GCN: [[COPY2:%[0-9]+]]:vgpr_32 = COPY [[COPY1]]
+ ; GCN: [[COPY3:%[0-9]+]]:vgpr_32 = COPY [[COPY]]
+ ; GCN: KILL [[COPY3]], implicit [[COPY2]]
+ %0:vgpr_32 = COPY $vgpr0
+ %1:vgpr_32 = COPY $vgpr1
+ %2:vreg_64 = REG_SEQUENCE %0, %subreg.sub0, %1, %subreg.sub1
+ %3:vreg_64 = REG_SEQUENCE %2.sub1, %subreg.sub0, %2.sub0, %subreg.sub1
+ %4:vgpr_32 = COPY %3.sub0
+ %5:vgpr_32 = COPY %3.sub1
+ KILL implicit %4, %5
+...
OpenPOWER on IntegriCloud