[llvm-bugs] [Bug 47703] New: Coalescer breaks case with undef lanes

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 1 09:09:06 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47703

            Bug ID: 47703
           Summary: Coalescer breaks case with undef lanes
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Register Allocator
          Assignee: unassignedbugs at nondot.org
          Reporter: Matthew.Arsenault at amd.com
                CC: llvm-bugs at lists.llvm.org, quentin.colombet at gmail.com

Created attachment 24014
  --> https://bugs.llvm.org/attachment.cgi?id=24014&action=edit
Reduced testcase

This testcase fails the verifier after the register coalescer with "No live
subrange at use". Before the coalescer, we have

---
name: no_live_subrange_at_use
tracksRegLiveness: true
body:             |
  bb.0:
    undef %0.sub1:vreg_96 = V_MOV_B32_e32 0, implicit $exec
    %0.sub2:vreg_96 = V_MOV_B32_e32 0, implicit $exec
    %1:vreg_96 = COPY killed %0
    $vgpr0 = COPY killed %1.sub0 # Reading undef sub0

...

The coalescer then correctly merges %0 with %1:
# After register coalescing
********** INTERVALS **********
%0 [16r,32r:0)[32r,64r:1)  0 at 16r 1 at 32r L000000000000000C [16r,16d:0)  0 at 16r
L0000000000000030 [32r,32d:0)  0 at 32r weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function no_live_subrange_at_use: NoPHIs, TracksLiveness

0B      bb.0:
16B       undef %0.sub1:vreg_96 = V_MOV_B32_e32 0, implicit $exec
32B       %0.sub2:vreg_96 = V_MOV_B32_e32 0, implicit $exec
64B       $vgpr0 = COPY %0.sub0:vreg_96

# End machine code for function no_live_subrange_at_use.

*** Bad machine code: No live subrange at use ***
- function:    no_live_subrange_at_use
- basic block: %bb.0  (0x838aa08) [0B;80B)
- instruction: 64B      $vgpr0 = COPY %0.sub0:vreg_96
- operand 1:   %0.sub0:vreg_96
- interval:    %0 [16r,32r:0)[32r,64r:1)  0 at 16r 1 at 32r L000000000000000C
[16r,16d:0)  0 at 16r L0000000000000030 [32r,32d:0)  0 at 32r weight:0.000000e+00
- at:          64B


If I take the coalesced function and compute fresh live intervals, it appears
to be equivalent, differing only in the slot index numbers:
# %0 [16r,32r:0)[32r,48r:1)  0 at 16r 1 at 32r L000000000000000C [16r,16d:0)  0 at 16r
L0000000000000030 [32r,32d:0)  0 at 32r weight:0.000000e+00
# RegMasks:
# ********** MACHINEINSTRS **********
# # Machine code for function no_live_subrange_at_use_post: NoPHIs,
TracksLiveness

# 0B    bb.0:
# 16B     undef %0.sub1:vreg_96 = V_MOV_B32_e32 0, implicit $exec
# 32B     %0.sub2:vreg_96 = V_MOV_B32_e32 0, implicit $exec
# 48B     $vgpr0 = COPY %0.sub0:vreg_96

This also fails the verifier. I would expect this to behave as if there were an
IMPLICIT_DEF of sub0 and sub2 on the first move, in which case this should be
valid MIR. It seems like the live range computation as well as the update done
by the coalescer are consistently wrong in not counting the final copy as a use

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201001/c95c58e2/attachment.html>


More information about the llvm-bugs mailing list