[PATCH] D52081: [InstCombine] do not expand 8 byte memcpy if optimising for minsize

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 15 07:19:37 PDT 2018


lebedev.ri added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:136
 
+  // Do not expand a 8 byte copy to load/stores when we optimise for minimum
+  // code size. This could for example expand into 2 word loads and
+  // 2 stores. But when unaligned data access is not supported, this is a
+  // lot worse and we will have 8 byte loads and 8 byte stores. Keeping the
+  // memcpy call will result in just 2 instructions: the call and a mov imm to
+  // an arg register for the number of bytes to copy.
+  auto F = MI->getParent()->getParent();
+  if (Size > 4 && F->hasFnAttribute(Attribute::MinSize))
+    return nullptr;
+
   if (Size > 8 || (Size&(Size-1)))
     return nullptr;  // If not 1/2/4/8 bytes, exit.
----------------
FWIW even this `8` shouldn't be here.
This should be two checks - power of two, and datalayout.


https://reviews.llvm.org/D52081





More information about the llvm-commits mailing list