diff options
| -rw-r--r-- | llvm/lib/CodeGen/MachineRegisterInfo.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 5 |
3 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp index dc109cd..c96de7a 100644 --- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp +++ b/llvm/lib/CodeGen/MachineRegisterInfo.cpp @@ -422,12 +422,8 @@ bool MachineRegisterInfo::hasOneNonDBGUser(Register RegNo) const { bool MachineRegisterInfo::hasAtMostUserInstrs(Register Reg, unsigned MaxUsers) const { - unsigned NumUsers = 0; - auto UI = use_instr_nodbg_begin(Reg), UE = use_instr_nodbg_end(); - for (; UI != UE && NumUsers < MaxUsers; ++UI) - NumUsers++; - // If we haven't reached the end yet then there are more than MaxUses users. - return UI == UE; + return hasNItemsOrLess(use_instr_nodbg_begin(Reg), use_instr_nodbg_end(), + MaxUsers); } /// clearKillFlags - Iterate over all the uses of the given register and diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 517e835..f7c1000 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -2325,7 +2325,7 @@ bool TargetLoweringBase::shouldLocalize(const MachineInstr &MI, auto maxUses = [](unsigned RematCost) { // A cost of 1 means remats are basically free. if (RematCost == 1) - return UINT_MAX; + return std::numeric_limits<unsigned>::max(); if (RematCost == 2) return 2U; diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 08ddab4..c21470d 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -20837,7 +20837,7 @@ bool AArch64TargetLowering::shouldLocalize( auto maxUses = [](unsigned RematCost) { // A cost of 1 means remats are basically free. if (RematCost == 1) - return UINT_MAX; + return std::numeric_limits<unsigned>::max(); if (RematCost == 2) return 2U; @@ -20867,6 +20867,9 @@ bool AArch64TargetLowering::shouldLocalize( unsigned RematCost = *Cost.getValue(); Register Reg = MI.getOperand(0).getReg(); unsigned MaxUses = maxUses(RematCost); + // Don't pass UINT_MAX sentinal value to hasAtMostUserInstrs(). + if (MaxUses == std::numeric_limits<unsigned>::max()) + --MaxUses; return MRI.hasAtMostUserInstrs(Reg, MaxUses); } // If we legalized G_GLOBAL_VALUE into ADRP + G_ADD_LOW, mark both as being |
