[all-commits] [llvm/llvm-project] f76ffc: [MCP] Invalidate copy for super register in copy s...
Jeffrey Byrnes via All-commits
all-commits at lists.llvm.org
Fri Aug 11 09:03:48 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f76ffc1f406ecdb5a8329e8a10a56f0ce2f6220c
https://github.com/llvm/llvm-project/commit/f76ffc1f406ecdb5a8329e8a10a56f0ce2f6220c
Author: Jeffrey Byrnes <Jeffrey.Byrnes at amd.com>
Date: 2023-08-11 (Fri, 11 Aug 2023)
Changed paths:
M llvm/lib/CodeGen/MachineCopyPropagation.cpp
A llvm/test/CodeGen/AMDGPU/mcp-use-before-def.mir
Log Message:
-----------
[MCP] Invalidate copy for super register in copy source
We must also track the super sources of a copy, otherwise we introduce a sort of subtle bug.
Consider:
1. DEF r0:r1
2. USE r1
3. r6:r9 = COPY r10:r13
4. r14:15 = COPY r0:r1
5. USE r6
6.. r1:4 = COPY r6:9
BackwardCopyPropagateBlock processes the instructions from bottom up. After processing 6., we will have propagatable copy for r1-r4 and r6-r9. After 5., we invalidate and erase the propagatble copy for r1-r4 and r6 but not for r7-r9.
The issue is that when processing 3., data structures still say we have valid copies for dest regs r7-r9 (from 6.). The corresponding defs for these registers in 6. are r1:r4, which we mark as registers to invalidate. When invalidating, we find the copy that corresponds to r1 is 4. (this was added when processing 4.), and we say that r1 now maps to unpropagatable copies. Thus, when we process 2., we do not have a valid copy, but when we process 1. we do -- because the mapped copy for subregister r0 was never invalidated.
The net result is to propagate the copy from 4. to 1., and replace DEF r0:r1 with DEF r14:r15. Then, we have a use before def in 2.
The main issue is that we have an inconsitent state between which def regs and which src regs are valid. When processing 5., we mark all the defs in 6. as invalid, but only the subreg use as invalid. Either we must only invalidate the individual subreg for both uses and defs, or the super register for both.
Differential Revision: https://reviews.llvm.org//D157564
Change-Id: I99d5e0b1a0d735e8ea3bd7d137b6464690aa9486
More information about the All-commits
mailing list