[PATCH] D64382: Use getMostFrequentByte to decide if should used memset+stores

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 21:31:08 PDT 2019


jfb added inline comments.


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:865
+/// initializer with equal or fewer than NumStores scalar stores.
+static bool canEmitStoresForInitAfterMemset(CodeGenModule &CGM,
+                                            llvm::Constant *Init,
----------------
You should update the return value to `Optional<Value*>` where the non-`None` return is the bytewise value.


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:873
     return true;
-  if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
+  if (BWInit || isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
       isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
----------------
I'm not sure I understand what this bit does. If something isn't a bytewise value then we now automatically assume it can be stored to with a single store. That's not necessarily true. I think you need to drop `BWInit ||` from here, and conditionalize this entire branch with `if (BWInit)` instead (so, an `&&` on it all).


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:888
     return true;
   }
 
----------------
The recursion now allows different values for `BWInit` on each sub-element.


================
Comment at: clang/lib/CodeGen/CGDecl.cpp:895
+    return true;
+  }
+
----------------
What does this new loop do? It'll only ever go around the loop once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64382





More information about the cfe-commits mailing list