[PATCH] D64382: Use getMostFrequentByte to decide if should used memset+stores
Vitaly Buka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 9 03:11:30 PDT 2019
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.
================
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) ||
----------------
vitalybuka wrote:
> jfb wrote:
> > 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).
> If value is bytewise, we will emit BWInit
>> If value is bytewise, we will emit BWInit
If value is bytewise, we will emit memset, which we can count as one store.
It's not always true that memset costs as a single store. However this is a heuristic, as the limit 6 itself.
Here I try to keep behavior close to original for zeroes.
In future patches I'd like to try to remove this function and use just "density" ((count memset bytes that match initializer)/(full size of initializer)). This will be simpler, should work good enough for exiting cases, and cover new cases with large initializers where 6 is not enough,
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