@@ -710,30 +710,6 @@ void LiveIntervals::pruneValue(LiveRange &LR, SlotIndex Kill,
710
710
// Register allocator hooks.
711
711
//
712
712
713
- // / Returns true if the physreg has multiple regunits that can be accessed
714
- // / as independent registers.
715
- // /
716
- // / Returns 'true' for e.g.:
717
- // / gpr64_0_gpr64_1
718
- // => two independently accessible registers gpr64_0 and gpr64_1.
719
- // /
720
- // / Returns 'false' for e.g.:
721
- // / gpr64_0: => accessible register, reads/writes 64bits
722
- // / gpr32_0: => accessible sub-regsiter of gpr64_0, reads/writes 32bits
723
- // gpr32_0_hi => top 32bits of gpr64_0, not independently accessible.
724
- static bool hasMultipleAddressableRegUnits (const TargetRegisterInfo *TRI,
725
- MCPhysReg PhysReg) {
726
- unsigned NumAddressableRegUnits = 0 ;
727
- for (MCRegUnit U : TRI->regunits (PhysReg)) {
728
- for (MCRegUnitRootIterator RI (U, TRI); RI.isValid (); ++RI)
729
- if (!TRI->isArtificial (*RI) && TRI->isInAllocatableClass (*RI))
730
- NumAddressableRegUnits++;
731
- if (NumAddressableRegUnits > 1 )
732
- return true ;
733
- }
734
- return false ;
735
- }
736
-
737
713
void LiveIntervals::addKillFlags (const VirtRegMap *VRM) {
738
714
// Keep track of regunit ranges.
739
715
SmallVector<std::pair<const LiveRange*, LiveRange::const_iterator>, 8 > RU;
@@ -760,18 +736,6 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) {
760
736
continue ;
761
737
RU.push_back (std::make_pair (&RURange, RURange.find (LI.begin ()->end )));
762
738
}
763
-
764
- // If parts of a physical register for a given liverange, as assigned by the
765
- // register allocator, can be used to store other values not represented by
766
- // this liverange, then `LiveIntervals::addKillFlags` normally avoids adding
767
- // a kill flag on the use of this register when the value's liverange ends.
768
- //
769
- // However, if all the other regunits are artificial, then we can still
770
- // safely add the kill flag, since those parts of the register can never be
771
- // accessed independently.
772
- bool AssumeOtherUnitsCanBeUsed =
773
- hasMultipleAddressableRegUnits (TRI, PhysReg);
774
-
775
739
// Every instruction that kills Reg corresponds to a segment range end
776
740
// point.
777
741
for (LiveInterval::const_iterator RI = LI.begin (), RE = LI.end (); RI != RE;
@@ -806,6 +770,9 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) {
806
770
if (MRI->subRegLivenessEnabled ()) {
807
771
// When reading a partial undefined value we must not add a kill flag.
808
772
// The regalloc might have used the undef lane for something else.
773
+ // If the register consists of a single allocatable subreg, then
774
+ // we can assume the other (undef) lanes cannot be used.
775
+ //
809
776
// Example:
810
777
// %1 = ... ; R32: %1
811
778
// %2:high16 = ... ; R64: %2
@@ -816,7 +783,7 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) {
816
783
// are actually never written by %2. After assignment the <kill>
817
784
// flag at the read instruction is invalid.
818
785
LaneBitmask DefinedLanesMask;
819
- if (LI.hasSubRanges () && AssumeOtherUnitsCanBeUsed ) {
786
+ if (LI.hasSubRanges () && TRI-> getNumAllocatableSubRegs (PhysReg) > 1 ) {
820
787
// Compute a mask of lanes that are defined.
821
788
DefinedLanesMask = LaneBitmask::getNone ();
822
789
for (const LiveInterval::SubRange &SR : LI.subranges ())
0 commit comments