|
18 | 18 | #include "llvm/ADT/SmallVector.h"
|
19 | 19 | #include "llvm/ADT/Statistic.h"
|
20 | 20 | #include "llvm/ADT/StringRef.h"
|
| 21 | +#include "llvm/CodeGen/LivePhysRegs.h" |
21 | 22 | #include "llvm/CodeGen/MachineBasicBlock.h"
|
22 | 23 | #include "llvm/CodeGen/MachineFunction.h"
|
23 | 24 | #include "llvm/CodeGen/MachineFunctionPass.h"
|
@@ -103,14 +104,6 @@ char SystemZElimCompare::ID = 0;
|
103 | 104 |
|
104 | 105 | } // end anonymous namespace
|
105 | 106 |
|
106 |
| -// Return true if CC is live out of MBB. |
107 |
| -static bool isCCLiveOut(MachineBasicBlock &MBB) { |
108 |
| - for (auto SI = MBB.succ_begin(), SE = MBB.succ_end(); SI != SE; ++SI) |
109 |
| - if ((*SI)->isLiveIn(SystemZ::CC)) |
110 |
| - return true; |
111 |
| - return false; |
112 |
| -} |
113 |
| - |
114 | 107 | // Returns true if MI is an instruction whose output equals the value in Reg.
|
115 | 108 | static bool preservesValueOf(MachineInstr &MI, unsigned Reg) {
|
116 | 109 | switch (MI.getOpcode()) {
|
@@ -595,7 +588,9 @@ bool SystemZElimCompare::processBlock(MachineBasicBlock &MBB) {
|
595 | 588 | // Walk backwards through the block looking for comparisons, recording
|
596 | 589 | // all CC users as we go. The subroutines can delete Compare and
|
597 | 590 | // instructions before it.
|
598 |
| - bool CompleteCCUsers = !isCCLiveOut(MBB); |
| 591 | + LivePhysRegs LiveRegs(*TRI); |
| 592 | + LiveRegs.addLiveOuts(MBB); |
| 593 | + bool CompleteCCUsers = !LiveRegs.contains(SystemZ::CC); |
599 | 594 | SmallVector<MachineInstr *, 4> CCUsers;
|
600 | 595 | MachineBasicBlock::iterator MBBI = MBB.end();
|
601 | 596 | while (MBBI != MBB.begin()) {
|
|
0 commit comments