[PATCH] D24103: [WIP][peephole] Enhance folding logic to work for STATEPOINTs

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 2 17:26:59 PDT 2016


wmi added inline comments.

================
Comment at: lib/CodeGen/PeepholeOptimizer.cpp:1683
@@ +1682,3 @@
+        // Note: This is O(n^2) in the number of operands if
+        // TII->optimizeLoadInstr were to fail for every other operand.
+        while(true) {
----------------
Why recursive folding is needed here? I guess it is trying to fold the case that the address of a load is another load? If that is true, can we put the use operands of newly folded load into a set and only visit the set in the next iteration?

================
Comment at: lib/Target/X86/X86InstrInfo.cpp:5336
@@ -5334,2 +5335,3 @@
+  // opposed to a set of FoldAsLoadDefs?  Can we remove?
   if (FoldAsLoadDefReg == 0)
     return nullptr;
----------------
Looks like FoldAsLoadDefReg will never be 0 here.

================
Comment at: lib/Target/X86/X86InstrInfo.cpp:5348
@@ -5340,2 +5347,3 @@
   }
+#endif
 
----------------
If MI is load, foldMemoryOperand will return nullptr in the end after it goes through a lot of effort.  I agree with you it is better to remove the check here and add an early exit in foldMemoryOperand.


https://reviews.llvm.org/D24103





More information about the llvm-commits mailing list