[PATCH] D11198: Avoid insertion sorting each new range in MemCpyOptimizer

Nick Lewycky nlewycky at google.com
Wed Jul 15 17:51:33 PDT 2015


nlewycky added a subscriber: nlewycky.
nlewycky added a comment.

I'm worried about the memory usage of storing all of them. It feels like you traded CPU time for more memory when you didn't need to.

The problem was that it did a linear scan to find the range with the nearest start value. That list is already stored sorted. Why not just use bisection (std::lower_bound) to find it, saving CPU time without increasing memory usage?


================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:258
@@ +257,3 @@
+  range_iterator E = Ranges.end();
+  range_iterator HEAD = I++;
+
----------------
Should be named "Head". See http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly .

================
Comment at: lib/Transforms/Scalar/MemCpyOptimizer.cpp:403-404
@@ -438,1 +402,4 @@
 
+  // Merge overlapping ranges.
+  Ranges.mergeRanges();
+
----------------
I don't have a suggestion, but I think the terminology of add/merge feels weird. You're really doing an enqueue (to be resolved later) and then resolve, but that's not much better working.


Repository:
  rL LLVM

http://reviews.llvm.org/D11198







More information about the llvm-commits mailing list