Skip to content

Commit 46039ce

Browse files
author
chengjunp
committed
Not do tree merge when only having one store
1 parent a30ca09 commit 46039ce

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,8 +2988,8 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
29882988
if (!TheLoad)
29892989
return std::nullopt;
29902990

2991-
// If we do not have any stores, we cannot do the tree structured merge
2992-
if (StoreInfos.empty())
2991+
// If we do not have multiple stores, we cannot do the tree structured merge
2992+
if (StoreInfos.size() < 2)
29932993
return std::nullopt;
29942994

29952995
// The load and store element types should be the same

llvm/test/Transforms/SROA/vector-promotion-cannot-tree-structure-merge.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ entry:
8888
%alloca = alloca <4 x float>
8989

9090
%ptr0 = getelementptr inbounds <4 x float>, ptr %alloca, i32 0, i32 0
91-
%float_vec = insertelement <2 x float> undef, float 1.0, i32 0
91+
%float_vec = insertelement <2 x float> poison, float 1.0, i32 0
9292
%float_vec2 = insertelement <2 x float> %float_vec, float 2.0, i32 1
9393
store <2 x float> %float_vec2, ptr %ptr0
9494

9595
%ptr1 = getelementptr inbounds <4 x float>, ptr %alloca, i32 0, i32 2
96-
%int_vec = insertelement <2 x i32> undef, i32 3, i32 0
96+
%int_vec = insertelement <2 x i32> poison, i32 3, i32 0
9797
%int_vec2 = insertelement <2 x i32> %int_vec, i32 4, i32 1
9898
store <2 x i32> %int_vec2, ptr %ptr1
9999

@@ -106,12 +106,12 @@ entry:
106106
%alloca = alloca <4 x float>
107107

108108
%ptr0 = getelementptr inbounds <4 x float>, ptr %alloca, i32 0, i32 0
109-
%float_vec = insertelement <2 x float> undef, float 1.0, i32 0
109+
%float_vec = insertelement <2 x float> poison, float 1.0, i32 0
110110
%float_vec2 = insertelement <2 x float> %float_vec, float 2.0, i32 1
111111
store <2 x float> %float_vec2, ptr %ptr0
112112

113113
%ptr1 = getelementptr inbounds <4 x float>, ptr %alloca, i32 0, i32 2
114-
%float_vec3 = insertelement <2 x float> undef, float 3.0, i32 0
114+
%float_vec3 = insertelement <2 x float> poison, float 3.0, i32 0
115115
%float_vec4 = insertelement <2 x float> %float_vec3, float 4.0, i32 1
116116
store <2 x float> %float_vec4, ptr %ptr1
117117

0 commit comments

Comments
 (0)