[PATCH] D151848: [X86, Peephole] Enable FoldImmediate for X86

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 21:55:09 PDT 2023


davidxl added a comment.

Looking at the test case changes, it looks like the change produce fewer instructions and reduces register pressure as well (smaller prologue).



================
Comment at: llvm/lib/CodeGen/PeepholeOptimizer.cpp:223
+                           DenseMap<RegSubRegPair, MachineInstr *> &CopyMIs,
+                           SmallPtrSetImpl<MachineInstr *> &LocalMIs);
 
----------------
add documentation on the new parameter LocalMIs


================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:3834
 
 bool X86InstrInfo::getConstValDefinedInReg(const MachineInstr &MI,
                                            const Register Reg,
----------------
Add documentation that it follows use-def for subreg2reg instruction to find the real movImm instruction.


================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:4791
+  // immediate if it has more than 1 use and we are optimizing for size.
+  if (UseMI.getMF()->getFunction().hasOptSize() && Reg.isVirtual() &&
+      !MRI->hasOneNonDBGUse(Reg))
----------------
Add a test case for optsize case?


================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:4798
+  switch (Opc) {
+  case TargetOpcode::COPY: {
+    Register ToReg = UseMI.getOperand(0).getReg();
----------------
Are all the opcode below covered by test cases?


================
Comment at: llvm/lib/Target/X86/X86InstrInfo.cpp:4857
+    break;
+  case X86::OR64rr:
+    NewOpc = X86::OR64ri32;
----------------
Add brief description for each case (on the transformation)?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151848/new/

https://reviews.llvm.org/D151848



More information about the llvm-commits mailing list