[PATCH] D23942: Do not abort on unresolved conflicts when joining subranges
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 05:37:51 PDT 2016
kparzysz added inline comments.
================
Comment at: lib/CodeGen/RegisterCoalescer.cpp:2342-2373
@@ -2341,3 +2341,34 @@
<< '@' << LR.getValNumInfo(i)->def << '\n');
- if (SubRangeJoin)
- return false;
+ if (SubRangeJoin) {
+ // Unresolved subrange conflicts may remain here as a result of merging
+ // registers where subregister definitions of one register are
+ // overwritten by corresponding definitions of the other register.
+ // For example, in this case, whem coalescing vreg140 into vreg131:
+ // 704B %vreg140<def> = ...
+ // 720B %vreg131<def> = COPY %vreg140
+ // 736B %vreg131:sub1<def> = COPY %vreg48
+ // 768B %vreg131:sub2<def> = COPY %vreg23
+ // 800B %vreg131:sub3<def> = COPY %vreg24
+ // 832B %vreg131:sub4<def> = COPY %vreg25
+ // 864B %vreg131:sub5<def> = COPY %vreg26
+ // 896B %vreg131:sub6<def> = COPY %vreg40
+ // 928B %vreg131:sub7<def> = COPY %vreg42
+ // 960B %vreg131:sub8<def> = COPY %vreg44
+ // 976B ... = use %vreg131
+ // 1008B %vreg140:sub1<def> = COPY %vreg54
+ // 1040B %vreg140:sub2<def> = COPY %vreg23
+ // 1072B %vreg140:sub3<def> = COPY %vreg24
+ // 1104B %vreg140:sub4<def> = COPY %vreg25
+ // 1136B %vreg140:sub5<def> = COPY %vreg26
+ // 1168B %vreg140:sub6<def> = COPY %vreg50
+ // 1200B %vreg140:sub7<def> = COPY %vreg51
+ // 1232B %vreg140:sub8<def> = COPY %vreg52
+ // 1248B ... = use %vreg140
+ // The conflict resolution for the main live ranges of both registers
+ // can determine that the coalescing is legal and may proceed, but the
+ // subregister ranges will still contain conflicts, since the subranges
+ // will overlap between the two virtual registers. Since repeating of
+ // the resolution code below for subregisters could only result in
+ // CR_Replace, and the legality has already been determined, assume
+ // the resolution to be CR_Replace without repeating the work.
+ V.Resolution = CR_Replace;
----------------
MatzeB wrote:
> I am trying to understand this, let's look at :sub1 for example: It is defined in 736 and read in 976, in that time :sub1 of vreg140 cannot be live or the join would be invalid. After that :sub1 is written in 1008 and read in 1248, in this time vreg131:sub1 cannot be live or the join would be invalid. I don't see an overlap in the subregisters here.
Sub1 may not be the best choice here. Consider sub2 instead: vreg140:sub2 is first defined in 704, then it is live until 1008 and subsequently overwritten in 1040. The live subrange for it will be [704,1008)[1040,1248). This will overlap with the live range for vreg131:sub2. The join of vreg131 and vreg140 is valid, since all the lanes written via vreg131:subN = COPY ... are never actually used via vreg140:subN. They are considered "used" for the purpose of liveness tracking, but are not actually used by the program. The function resolveConflicts checks specifically for that (via taintExtent and usesLanes).
Repository:
rL LLVM
https://reviews.llvm.org/D23942
More information about the llvm-commits
mailing list