[llvm] c08896d - [AMDGPU] Return better Changed status from SILowerI1Copies
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 17 01:39:07 PST 2022
Author: Jay Foad
Date: 2022-02-17T09:38:57Z
New Revision: c08896d292562a4aa3f4a47494b6220b384e6078
URL: https://github.com/llvm/llvm-project/commit/c08896d292562a4aa3f4a47494b6220b384e6078
DIFF: https://github.com/llvm/llvm-project/commit/c08896d292562a4aa3f4a47494b6220b384e6078.diff
LOG: [AMDGPU] Return better Changed status from SILowerI1Copies
Differential Revision: https://reviews.llvm.org/D119946
Added:
Modified:
llvm/lib/Target/AMDGPU/SILowerI1Copies.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SILowerI1Copies.cpp b/llvm/lib/Target/AMDGPU/SILowerI1Copies.cpp
index 672266f0c11e..5fb545b50228 100644
--- a/llvm/lib/Target/AMDGPU/SILowerI1Copies.cpp
+++ b/llvm/lib/Target/AMDGPU/SILowerI1Copies.cpp
@@ -79,9 +79,9 @@ class SILowerI1Copies : public MachineFunctionPass {
}
private:
- void lowerCopiesFromI1();
- void lowerPhis();
- void lowerCopiesToI1();
+ bool lowerCopiesFromI1();
+ bool lowerPhis();
+ bool lowerCopiesToI1();
bool isConstantLaneMask(Register Reg, bool &Val) const;
void buildMergeLaneMasks(MachineBasicBlock &MBB,
MachineBasicBlock::iterator I, const DebugLoc &DL,
@@ -473,15 +473,17 @@ bool SILowerI1Copies::runOnMachineFunction(MachineFunction &TheMF) {
OrN2Op = AMDGPU::S_ORN2_B64;
}
- lowerCopiesFromI1();
- lowerPhis();
- lowerCopiesToI1();
+ bool Changed = false;
+ Changed |= lowerCopiesFromI1();
+ Changed |= lowerPhis();
+ Changed |= lowerCopiesToI1();
+ assert(Changed || ConstrainRegs.empty());
for (unsigned Reg : ConstrainRegs)
MRI->constrainRegClass(Reg, &AMDGPU::SReg_1_XEXECRegClass);
ConstrainRegs.clear();
- return true;
+ return Changed;
}
#ifndef NDEBUG
@@ -493,7 +495,8 @@ static bool isVRegCompatibleReg(const SIRegisterInfo &TRI,
}
#endif
-void SILowerI1Copies::lowerCopiesFromI1() {
+bool SILowerI1Copies::lowerCopiesFromI1() {
+ bool Changed = false;
SmallVector<MachineInstr *, 4> DeadCopies;
for (MachineBasicBlock &MBB : *MF) {
@@ -509,6 +512,8 @@ void SILowerI1Copies::lowerCopiesFromI1() {
if (isLaneMaskReg(DstReg) || isVreg1(DstReg))
continue;
+ Changed = true;
+
// Copy into a 32-bit vector register.
LLVM_DEBUG(dbgs() << "Lower copy from i1: " << MI);
DebugLoc DL = MI.getDebugLoc();
@@ -530,9 +535,10 @@ void SILowerI1Copies::lowerCopiesFromI1() {
MI->eraseFromParent();
DeadCopies.clear();
}
+ return Changed;
}
-void SILowerI1Copies::lowerPhis() {
+bool SILowerI1Copies::lowerPhis() {
MachineSSAUpdater SSAUpdater(*MF);
LoopFinder LF(*DT, *PDT);
PhiIncomingAnalysis PIA(*PDT);
@@ -550,6 +556,8 @@ void SILowerI1Copies::lowerPhis() {
Vreg1Phis.push_back(&MI);
}
}
+ if (Vreg1Phis.empty())
+ return false;
MachineBasicBlock *PrevMBB = nullptr;
for (MachineInstr *MI : Vreg1Phis) {
@@ -662,9 +670,11 @@ void SILowerI1Copies::lowerPhis() {
IncomingRegs.clear();
IncomingUpdated.clear();
}
+ return true;
}
-void SILowerI1Copies::lowerCopiesToI1() {
+bool SILowerI1Copies::lowerCopiesToI1() {
+ bool Changed = false;
MachineSSAUpdater SSAUpdater(*MF);
LoopFinder LF(*DT, *PDT);
SmallVector<MachineInstr *, 4> DeadCopies;
@@ -681,6 +691,8 @@ void SILowerI1Copies::lowerCopiesToI1() {
if (!isVreg1(DstReg))
continue;
+ Changed = true;
+
if (MRI->use_empty(DstReg)) {
DeadCopies.push_back(&MI);
continue;
@@ -731,6 +743,7 @@ void SILowerI1Copies::lowerCopiesToI1() {
MI->eraseFromParent();
DeadCopies.clear();
}
+ return Changed;
}
bool SILowerI1Copies::isConstantLaneMask(Register Reg, bool &Val) const {
More information about the llvm-commits
mailing list