[PATCH] D10914: Allow BranchFolding to operate on instructions with virtual registers
Dan Gohman
dan433584 at gmail.com
Thu Jul 2 20:59:08 PDT 2015
sunfish created this revision.
sunfish added a subscriber: llvm-commits-list.
By observing that virtual registers don't have aliases or subregisters in the way physical registers do, BranchFolding can work on instructions with virtual registers too.
http://reviews.llvm.org/D10914
Files:
lib/CodeGen/BranchFolding.cpp
Index: lib/CodeGen/BranchFolding.cpp
===================================================================
--- lib/CodeGen/BranchFolding.cpp
+++ lib/CodeGen/BranchFolding.cpp
@@ -1598,8 +1598,11 @@
if (!Reg)
continue;
if (MO.isUse()) {
- for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
- Uses.insert(*AI);
+ if (TargetRegisterInfo::isVirtualRegister(Reg))
+ Uses.insert(Reg);
+ else
+ for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
+ Uses.insert(*AI);
} else {
if (!MO.isDead())
// Don't try to hoist code in the rare case the terminator defines a
@@ -1608,8 +1611,11 @@
// If the terminator defines a register, make sure we don't hoist
// the instruction whose def might be clobbered by the terminator.
- for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
- Defs.insert(*AI);
+ if (TargetRegisterInfo::isVirtualRegister(Reg))
+ Defs.insert(Reg);
+ else
+ for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
+ Defs.insert(*AI);
}
}
@@ -1669,11 +1675,17 @@
Uses.insert(*AI);
} else {
if (Uses.erase(Reg)) {
- for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs)
- Uses.erase(*SubRegs); // Use sub-registers to be conservative
+ if (TargetRegisterInfo::isVirtualRegister(Reg))
+ Uses.erase(Reg);
+ else
+ for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs)
+ Uses.erase(*SubRegs); // Use sub-registers to be conservative
}
- for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
- Defs.insert(*AI);
+ if (TargetRegisterInfo::isVirtualRegister(Reg))
+ Defs.insert(Reg);
+ else
+ for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
+ Defs.insert(*AI);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10914.28988.patch
Type: text/x-patch
Size: 1963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150703/556faaf8/attachment.bin>
More information about the llvm-commits
mailing list