[PATCH] [Peephole] Advanced rewriting of copies to avoid cross register banks copies.

Quentin Colombet qcolombet at apple.com
Tue Jul 1 00:55:49 PDT 2014


================
Comment at: lib/CodeGen/PeepholeOptimizer.cpp:561
@@ -458,3 +560,3 @@
 
     if (TargetRegisterInfo::isPhysicalRegister(Src))
       break;
----------------
hfinkel at anl.gov wrote:
> What does not work for physical registers?
You do not want to extend the live-ranges of physical registers as they add constraints to the register allocator.
Moreover, if you allow to extend the live-range of a physical register, unlike SSA virtual register, you will have to check that you do not redefine that register.

================
Comment at: lib/CodeGen/PeepholeOptimizer.cpp:784
@@ +783,3 @@
+  if (Def->getDesc().getNumOperands() != 2)
+    return false;
+  if (Def->getOperand(DefIdx).getSubReg() != DefSubReg)
----------------
hfinkel at anl.gov wrote:
> Should this be an assert?
Good point.
If someone adds operand to a generic copy, I think we can yell at them :).

================
Comment at: lib/CodeGen/PeepholeOptimizer.cpp:798
@@ +797,3 @@
+  assert(Def->isBitcast() && "Invalid definition");
+
+  // Bitcasts with more than one def are not supported.
----------------
hfinkel at anl.gov wrote:
> Should we also bail is hasUnmodeledSideEffects?
Good point.
This was not part of the previous implementation, but that would be safer.

================
Comment at: lib/CodeGen/PeepholeOptimizer.cpp:981
@@ +980,3 @@
+    return getNextSourceFromInsertSubreg(SrcIdx, SrcSubReg);
+  if (Def->getOpcode() == TargetOpcode::EXTRACT_SUBREG)
+    return getNextSourceFromExtractSubreg(SrcIdx, SrcSubReg);
----------------
hfinkel at anl.gov wrote:
> I think you might as well add isExtractSubreg().
Agree.
Though, I did not want to do that in that patch.
I can either do it before or after this patch lands.
Any preference?

http://reviews.llvm.org/D4086






More information about the llvm-commits mailing list