[PATCH] D140697: [MemCpyOpt] Merge succeeding undefs while attempting a `memset`
Jamie Hill-Daniel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 27 14:16:12 PST 2022
clubby789 updated this revision to Diff 485423.
clubby789 added a comment.
clang-format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140697/new/
https://reviews.llvm.org/D140697
Files:
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Index: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -111,24 +111,26 @@
bool no_undef = true;
for (Instruction *SI : TheStores) {
if (auto *Store = dyn_cast<StoreInst>(SI)) {
- Value *StoredVal = Store->getValueOperand();
- if (!isa<UndefValue>(StoredVal))
- non_undef_stores++;
- else
- no_undef = false;
+ Value *StoredVal = Store->getValueOperand();
+ if (!isa<UndefValue>(StoredVal))
+ non_undef_stores++;
+ else
+ no_undef = false;
} else {
- // If any of the stores are a memset, then it is always good to extend the
- // memset.
- return true;
+ // If any of the stores are a memset, then it is always good to extend the
+ // memset.
+ return true;
}
}
// If we found more than 4 stores to merge or 16 bytes, use memset.
- if (non_undef_stores >= 4 || (no_undef && End-Start >= 16)) return true;
+ if (non_undef_stores >= 4 || (no_undef && End - Start >= 16))
+ return true;
// If there is nothing to merge, don't do anything.
// Assume that the code generator is capable of merging pairs of stores
// together if it wants to.
- if (non_undef_stores <= 2) return false;
+ if (non_undef_stores <= 2)
+ return false;
// If we have fewer than 8 stores, it can still be worthwhile to do this.
// For example, merging 4 i8 stores into an i32 store is useful almost always.
@@ -152,7 +154,7 @@
// If we will reduce the # stores (according to this heuristic), do the
// transformation. This encourages merging 4 x i8 -> i32 and 2 x i16 -> i32
// etc.
- return non_undef_stores > NumPointerStores+NumByteStores;
+ return non_undef_stores > NumPointerStores + NumByteStores;
}
namespace {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140697.485423.patch
Type: text/x-patch
Size: 1941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221227/a7ff6688/attachment.bin>
More information about the llvm-commits
mailing list