This is an archive of the discontinued LLVM Phabricator instance.

[LiveIntervals] Fix incorrect range (re)construction from subranges.
ClosedPublic

Authored by dfukalov on Jun 24 2022, 12:43 PM.

Details

Summary

After D82916 updateAllRanges() started to fix holes in main range with
subranges but it fails on instructions with two subregs def which are parts of
one reg. The main range constructed with all subranges of subregs just after
processing the first operand. So the main range gets intervals from subranges
those are not updated yet.

The patch takes into account lane mask to update the main range.

Diff Detail

Event Timeline

dfukalov created this revision.Jun 24 2022, 12:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 12:43 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
dfukalov requested review of this revision.Jun 24 2022, 12:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 24 2022, 12:43 PM
Herald added a subscriber: wdng. · View Herald Transcript
dfukalov added a comment.EditedJun 24 2022, 12:44 PM

LiveIntervals dumps for the test, before the patch:
Before first move:

%1 [16r,32r:0) 0@16r  L0000000000000003 [16r,32r:0) 0@16r  L000000000000000C [16r,32r:0) 0@16r  weight:0.000000e+00
%2 [32r,32d:0) 0@32r  weight:0.000000e+00
%3 [48r,64r:0)[64r,80r:1) 0@48r 1@64r  L0000000000000003 [48r,80r:0) 0@48r  L000000000000000C [64r,80r:0) 0@64r  weight:0.000000e+00
%4 [80r,80d:0) 0@80r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function func: NoPHIs

0B      bb.0:
16B       INLINEASM &"" [attdialect], $0:[regdef:VGPR_32], def undef %1.sub0:vreg_64, $1:[regdef:VGPR_32], def undef %1.sub1:vreg_64
32B       dead %2:vreg_64 = COPY %1:vreg_64
48B       undef %3.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
64B       %3.sub1:vreg_64 = COPY %3.sub0:vreg_64
80B       dead %4:vreg_64 = COPY %3:vreg_64

After the first move:

%1 [16r,72r:0) 0@16r  L0000000000000003 [16r,72r:0) 0@16r  L000000000000000C [16r,72r:0) 0@16r  weight:0.000000e+00
%2 [72r,72d:0) 0@72r  weight:0.000000e+00
%3 [48r,64r:0)[64r,80r:1) 0@48r 1@64r  L0000000000000003 [48r,80r:0) 0@48r  L000000000000000C [64r,80r:0) 0@64r  weight:0.000000e+00
%4 [80r,80d:0) 0@80r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function func: NoPHIs

0B      bb.0:
16B       INLINEASM &"" [attdialect], $0:[regdef:VGPR_32], def undef %1.sub0:vreg_64, $1:[regdef:VGPR_32], def undef %1.sub1:vreg_64
48B       undef %3.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
64B       %3.sub1:vreg_64 = COPY %3.sub0:vreg_64
72B       dead %2:vreg_64 = COPY %1:vreg_64
80B       dead %4:vreg_64 = COPY %3:vreg_64

After the second move, (main range got [16r,16d:1) in the constructMainRangeFromSubranges() before L000000000000000C was updated from [16r,72r:0) to [68r,72r:0))

%1 [16r,16d:1)[68r,72r:0) 0@68r 1@16r  L0000000000000003 [68r,72r:0) 0@68r  L000000000000000C [68r,72r:0) 0@68r  weight:0.000000e+00
%2 [72r,72d:0) 0@72r  weight:0.000000e+00
%3 [48r,64r:0)[64r,80r:1) 0@48r 1@64r  L0000000000000003 [48r,80r:0) 0@48r  L000000000000000C [64r,80r:0) 0@64r  weight:0.000000e+00
%4 [80r,80d:0) 0@80r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function func: NoPHIs

0B      bb.0:
48B       undef %3.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
64B       %3.sub1:vreg_64 = COPY %3.sub0:vreg_64
68B       INLINEASM &"" [attdialect], $0:[regdef:VGPR_32], def undef %1.sub0:vreg_64, $1:[regdef:VGPR_32], def undef %1.sub1:vreg_64
72B       dead %2:vreg_64 = COPY %1:vreg_64
80B       dead %4:vreg_64 = COPY %3:vreg_64

*** Bad machine code: No instruction at VNInfo def index ***
- function:    func
- basic block: %bb.0  (0x1bcd4b61968) [0B;96B)
- liverange:   [16r,16d:1)[68r,72r:0) 0@68r 1@16r
- v. register: %1
- ValNo:       1 (def 16r)
rampitec accepted this revision.Jun 24 2022, 1:15 PM

LGTM, thanks! Please allow other reviewers time to review it too though.

This revision is now accepted and ready to land.Jun 24 2022, 1:15 PM
arsenm accepted this revision.Jun 25 2022, 5:43 AM
This revision was landed with ongoing or failed builds.Jul 8 2022, 6:07 AM
This revision was automatically updated to reflect the committed changes.