Skip to content

Commit 3212e4b

Browse files
author
Artem Gindinson
committed
Disable partial overwrite tracking in LLVM 14 DSE via a patch
Starting from LLVM 14, Dead Store Elimination pass tends to perform `llvm.memset` shortening more often, and upon `memset` resolution, the resulting "extra" GEP to i8* cannot be consumed by our GEP lowering optimizations. Bypassing this behavior through an LLVM flag lets our memory optimizations produce the Long-term, we should try teaching our `LowerGEPForPrivMem` pass to understand these shortening sequences and investigate if this partial shortening by DSE could bring even more performance benefits. (cherry picked from commit d7c485d)
1 parent 864cf3a commit 3212e4b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*========================== begin_copyright_notice ============================
2+
3+
Copyright (C) 2023 Intel Corporation
4+
5+
SPDX-License-Identifier: MIT
6+
7+
============================= end_copyright_notice ===========================*/
8+
9+
/*========================== begin_copyright_notice ============================
10+
11+
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
12+
See https://llvm.org/LICENSE.txt for license information.
13+
SPDX-License-Identifier: Apache-2.0 with LLVM-exception
14+
15+
============================= end_copyright_notice ===========================*/
16+
17+
# Description:
18+
# Disable the option to avoid shortening of llvm.memset, which isn't supported
19+
# by our memset lowering / LowerGEPForPrivMem pass, and leads to suboptimal CG.
20+
#
21+
# Shortening sequence to avoid:
22+
# call void @llvm.memset.p0i8.i64(i8* %ptr, i8 0, i64 64, i1 false)
23+
# ->
24+
# %gep = getelementptr inbounds i8, i8* %ptr, i64 40
25+
# call void @llvm.memset.p0i8.i64(i8* %gep, i8 0, i64 24, i1 false)
26+
#
27+
# TODO: Improve memset handling / GEP to extract/insertelement lowering, then
28+
# abandon this patch.
29+
30+
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
31+
index c5c8e880e..e620493d8 100644
32+
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
33+
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
34+
@@ -113,7 +113,7 @@ DEBUG_COUNTER(MemorySSACounter, "dse-memoryssa",
35+
36+
static cl::opt<bool>
37+
EnablePartialOverwriteTracking("enable-dse-partial-overwrite-tracking",
38+
- cl::init(true), cl::Hidden,
39+
+ cl::init(false), cl::Hidden,
40+
cl::desc("Enable partial-overwrite tracking in DSE"));
41+
42+
static cl::opt<bool>
43+

0 commit comments

Comments
 (0)