[PATCH] D140697: [MemCpyOpt] Merge succeeding undefs while attempting a `memset`

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 27 11:59:28 PST 2022


nikic added a reviewer: nikic.
nikic added a comment.

I think there are two problems here:

1. Profitability: As implemented, I believe this will also transform some non-profitable cases, e.g. imagine a store 0, followed by one hundred store undef, followed by store 0. We'd rather make those two stores than one long memset. This needs some kind of profitability heuristic.

2. Phase ordering: InstCombine will remove store undef, and it runs before MemCpyOpt. So MemCpyOpt will actually never see this kind of IR (except in degenerate cases) and this change will not make any difference in end-to-end compilation.



================
Comment at: llvm/test/Transforms/MemCpyOpt/merge-undef-memset.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -memcpyopt -opaque-pointers -S -verify-memoryssa | FileCheck %s
+
----------------
Please:

 * Use update_test_checks.py.
 * Fully convert the test to opaque pointers and remove the `-opaque-pointers` flag.
 * Drop the unnecessary datalayout (unless I'm missing something?)
 * Name instructions in test (run through `opt -S -passes=instnamer`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140697



More information about the llvm-commits mailing list