[llvm] [X86] Convert X86FixupBWInsts from LivePhysRegs to LiveRegUnits. NFCI. (PR #65592)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 06:35:15 PDT 2023
================
@@ -202,22 +202,22 @@ Register FixupBWInstPass::getSuperRegDestIfDead(MachineInstr *OrigMI) const {
if (SubRegIdx == X86::sub_8bit_hi)
return Register();
- // If neither the destination-super register nor any applicable subregisters
- // are live after this instruction, then the super register is safe to use.
- if (!LiveRegs.contains(SuperDestReg)) {
- // If the original destination register was not the low 8-bit subregister
- // then the super register check is sufficient.
- if (SubRegIdx != X86::sub_8bit)
- return SuperDestReg;
- // If the original destination register was the low 8-bit subregister and
- // we also need to check the 16-bit subregister and the high 8-bit
- // subregister.
- MCRegister HighReg = getX86SubSuperRegister(SuperDestReg, 8, /*High=*/true);
- if (!LiveRegs.contains(getX86SubSuperRegister(OrigDestReg, 16)) &&
- (!HighReg.isValid() || !LiveRegs.contains(HighReg)))
- return SuperDestReg;
- // Otherwise, we have a little more checking to do.
+ // Test all regunits of the super register that are not part of the
+ // sub register. If none of them are live then the super register is safe to
+ // use.
+ bool SuperIsLive = false;
+ auto Range = TRI->regunits(OrigDestReg);
+ MCRegUnitIterator I = Range.begin(), E = Range.end();
+ for (MCRegUnit S : TRI->regunits(SuperDestReg)) {
+ while (I != E && *I < S)
+ ++I;
+ if ((I == E || *I > S) && LiveUnits.getBitVector().test(S)) {
----------------
jayfoad wrote:
Yup - at least with std::lower_bound.
https://github.com/llvm/llvm-project/pull/65592
More information about the llvm-commits
mailing list