[PATCH] D49097: [RegisterCoalescer] Another fix for subrange join unreachable

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 11 08:30:19 PDT 2018


kparzysz added a comment.

Here's how the problem happens:

Consider the following snippet, and vregs `%19` and `%34`.

  512B    bb.14.bb19:
          ; predecessors: %bb.9, %bb.12, %bb.13
            successors: %bb.15(0x40000000), %bb.16(0x40000000); %bb.15(50.00%), %bb.16(50.00%)
                  
  528B      undef %34.sub2:sreg_128 = S_MOV_B32 0
  560B      S_CBRANCH_SCC0 %bb.16, implicit undef $scc
                  
  576B    bb.15:  
          ; predecessors: %bb.14
            successors: %bb.17(0x80000000); %bb.17(100.00%)
                  
  592B      undef %35.sub0:sreg_128 = COPY %34.sub2:sreg_128
  656B      S_BRANCH %bb.17 
                  
  672B    bb.16.bb22:
          ; predecessors: %bb.14  
            successors: %bb.17(0x80000000); %bb.17(100.00%)
                  
  688B      undef %19.sub0:sreg_128 = COPY %34.sub2:sreg_128
  704B      %19.sub1:sreg_128 = COPY %34.sub2:sreg_128
  720B      %19.sub2:sreg_128 = COPY %34.sub2:sreg_128                                                            
  736B      %17:sreg_128 = COPY %19:sreg_128
  752B      %16:sreg_128 = COPY %34:sreg_128                                                                      
  768B      %34:sreg_128 = COPY %16:sreg_128
  784B      %35:sreg_128 = COPY %17:sreg_128

In `%34` only `sub2` (lane mask L00000004) is defined, and so the "full" use at 752 is not reflected in the subranges for other subregisters:

  %34 [528r,752r:1)[768r,800B:0)[800B,848r:2)  0 at 768r 1 at 528r 2 at 800B-phi L00000004 [528r,752r:1)[768r,800B:0)[800B,848r:2)  0 at 768r 1 at 528r 2 at 800B-phi L0000000B [768r,768d:0)  0 at 768r 1 at x 2 at x

When the copy at 688 is coalesced into `%19`, subregisters other than `sub2` are now live prior to 752, and the use of (now) `%19` is using all defined subregisters:

  688B      %19.sub0:sreg_128 = COPY %19.sub2:sreg_128
  704B      %19.sub1:sreg_128 = COPY %19.sub2:sreg_128
  736B      %17:sreg_128 = COPY %19:sreg_128
  752B      %16:sreg_128 = COPY %19:sreg_128
  768B      %19:sreg_128 = COPY %16:sreg_128
  784B      %35:sreg_128 = COPY %17:sreg_128

This is, however, not reflected in the live interval for `%19`. Notice that subranges for `sub0` (L0000001) and `sub1` (L00000002) end before 752:

  %19 [528r,688r:0)[688r,704r:1)[704r,752r:2)[768r,800B:3)[800B,848r:4)  0 at 528r 1 at 688r 2 at 704r 3 at 768r 4 at 800B-phi L00000008 [768r,768d:0)  0 at 768r 1 at x 2 at x L00000001 [688r,736r:0)[768r,768d:1)  0 at 688r 1 at 768r 2 at x 3 at x L00000002 [704r,736r:0)[768r,768d:1)  0 at 704r 1 at 768r 2 at x 3 at x L00000004 [528r,752r:0)[768r,800B:1)[800B,848r:2)  0 at 528r 1 at 768r 2 at 800B-phi weight:0.000000e+00

This leads to an assertion when the coalescer tries to coalesce `%19` and `%17` at 736.


Repository:
  rL LLVM

https://reviews.llvm.org/D49097





More information about the llvm-commits mailing list