diff options
author | Michael Zolotukhin <mzolotukhin@apple.com> | 2018-05-04 01:40:05 +0000 |
---|---|---|
committer | Michael Zolotukhin <mzolotukhin@apple.com> | 2018-05-04 01:40:05 +0000 |
commit | 131e74910cdbfedd3256c437f16050958c428f58 (patch) | |
tree | 8f8107482ad6b9e843a18e9b9c4941de1c3421c1 /llvm/lib/CodeGen/MachineCSE.cpp | |
parent | 0fd685353df630653563da658fe04c566a7d24c4 (diff) | |
download | bcm5719-llvm-131e74910cdbfedd3256c437f16050958c428f58.tar.gz bcm5719-llvm-131e74910cdbfedd3256c437f16050958c428f58.zip |
[MachineCSE] Rewrite a loop checking if a block is in a set of blocks without using a set. NFC.
Summary:
Using a set is unnecessary here an in some cases (see e.g. PR37277)
takes significant amount of time to just insert values into it. In this
particular case all we need is just to check if we find the block we are
looking for or not.
Reviewers: davide
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D46411
llvm-svn: 331502
Diffstat (limited to 'llvm/lib/CodeGen/MachineCSE.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineCSE.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp index 8b7d2980ac8..ce8503427ea 100644 --- a/llvm/lib/CodeGen/MachineCSE.cpp +++ b/llvm/lib/CodeGen/MachineCSE.cpp @@ -445,15 +445,13 @@ bool MachineCSE::isProfitableToCSE(unsigned CSReg, unsigned Reg, // Heuristics #3: If the common subexpression is used by PHIs, do not reuse // it unless the defined value is already used in the BB of the new use. bool HasPHI = false; - SmallPtrSet<MachineBasicBlock*, 4> CSBBs; - for (MachineInstr &MI : MRI->use_nodbg_instructions(CSReg)) { - HasPHI |= MI.isPHI(); - CSBBs.insert(MI.getParent()); + for (MachineInstr &UseMI : MRI->use_nodbg_instructions(CSReg)) { + HasPHI |= UseMI.isPHI(); + if (UseMI.getParent() == MI->getParent()) + return true; } - if (!HasPHI) - return true; - return CSBBs.count(MI->getParent()); + return !HasPHI; } void MachineCSE::EnterScope(MachineBasicBlock *MBB) { |