Revert "Fix merges of non-zero vector stores"
authorReid Kleckner <reid@kleckner.net>
Thu, 11 Jun 2015 17:25:24 +0000 (17:25 +0000)
committerReid Kleckner <reid@kleckner.net>
Thu, 11 Jun 2015 17:25:24 +0000 (17:25 +0000)
This reverts commit r239539.

It was causing SDAG assertions while building freetype.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239543 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/R600/merge-stores.ll
test/CodeGen/X86/2012-11-28-merge-store-alias.ll

index 4ffb4099e7fa18942ac791a1017781bdb01b79e8..a71c6761c75f780e73443c2c181f4b556d95ba76 100644 (file)
@@ -387,13 +387,6 @@ namespace {
       unsigned SequenceNum;
     };
 
-    /// This is a helper function for MergeStoresOfConstantsOrVecElts. Returns a
-    /// constant build_vector of the stored constant values in Stores.
-    SDValue getMergedConstantVectorStore(SelectionDAG &DAG,
-                                         SDLoc SL,
-                                         ArrayRef<MemOpLink> Stores,
-                                         EVT Ty) const;
-
     /// This is a helper function for MergeConsecutiveStores. When the source
     /// elements of the consecutive stores are all constants or all extracted
     /// vector elements, try to merge them into one larger store.
@@ -10583,17 +10576,6 @@ struct BaseIndexOffset {
 };
 } // namespace
 
-SDValue DAGCombiner::getMergedConstantVectorStore(SelectionDAG &DAG,
-                                                  SDLoc SL,
-                                                  ArrayRef<MemOpLink> Stores,
-                                                  EVT Ty) const {
-  SmallVector<SDValue, 8> BuildVector;
-
-  for (const MemOpLink &Store : Stores)
-    BuildVector.push_back(cast<StoreSDNode>(Store.MemNode)->getValue());
-  return DAG.getNode(ISD::BUILD_VECTOR, SL, Ty, BuildVector);
-}
-
 bool DAGCombiner::MergeStoresOfConstantsOrVecElts(
                   SmallVectorImpl<MemOpLink> &StoreNodes, EVT MemVT,
                   unsigned NumElem, bool IsConstantSrc, bool UseVector) {
@@ -10624,7 +10606,12 @@ bool DAGCombiner::MergeStoresOfConstantsOrVecElts(
     EVT Ty = EVT::getVectorVT(*DAG.getContext(), MemVT, NumElem);
     assert(TLI.isTypeLegal(Ty) && "Illegal vector store");
     if (IsConstantSrc) {
-      StoredVal = getMergedConstantVectorStore(DAG, DL, StoreNodes, Ty);
+      // A vector store with a constant source implies that the constant is
+      // zero; we only handle merging stores of constant zeros because the zero
+      // can be materialized without a load.
+      // It may be beneficial to loosen this restriction to allow non-zero
+      // store merging.
+      StoredVal = DAG.getConstant(0, DL, Ty);
     } else {
       SmallVector<SDValue, 8> Ops;
       for (unsigned i = 0; i < NumElem ; ++i) {
index fea3e834c8beede591d3ed018c972d3361698f92..dbf9d4481ffb1bb8943d50f6fdf21955d2e8e753 100644 (file)
@@ -89,11 +89,7 @@ define void @merge_global_store_2_constants_i32_f32(i32 addrspace(1)* %out) #0 {
 }
 
 ; GCN-LABEL: {{^}}merge_global_store_2_constants_f32_i32:
-; SI-DAG: s_mov_b32 [[SLO:s[0-9]+]], 4.0
-; SI-DAG: s_movk_i32 [[SHI:s[0-9]+]], 0x7b{{$}}
-; SI-DAG: v_mov_b32_e32 v[[VLO:[0-9]+]], [[SLO]]
-; SI-DAG: v_mov_b32_e32 v[[VHI:[0-9]+]], [[SHI]]
-; GCN: buffer_store_dwordx2 v{{\[}}[[VLO]]:[[VHI]]{{\]}}
+; GCN: buffer_store_dwordx2
 define void @merge_global_store_2_constants_f32_i32(float addrspace(1)* %out) #0 {
   %out.gep.1 = getelementptr float, float addrspace(1)* %out, i32 1
   %out.gep.1.bc = bitcast float addrspace(1)* %out.gep.1 to i32 addrspace(1)*
@@ -103,11 +99,7 @@ define void @merge_global_store_2_constants_f32_i32(float addrspace(1)* %out) #0
 }
 
 ; GCN-LABEL: {{^}}merge_global_store_4_constants_i32:
-; GCN-DAG: v_mov_b32_e32 v[[HI:[0-9]+]], 0x14d{{$}}
-; GCN-DAG: v_mov_b32_e32 v{{[0-9]+}}, 0x1c8{{$}}
-; GCN-DAG: v_mov_b32_e32 v{{[0-9]+}}, 0x7b{{$}}
-; GCN-DAG: v_mov_b32_e32 v[[LO:[0-9]+]], 0x4d2{{$}}
-; GCN: buffer_store_dwordx4 v{{\[}}[[LO]]:[[HI]]{{\]}}
+; GCN: buffer_store_dwordx4
 define void @merge_global_store_4_constants_i32(i32 addrspace(1)* %out) #0 {
   %out.gep.1 = getelementptr i32, i32 addrspace(1)* %out, i32 1
   %out.gep.2 = getelementptr i32, i32 addrspace(1)* %out, i32 2
index c16deeff3d99a01d47d1dbb0606ee63119a8e029..ed1daadf6297c8e2408c78fb2fc3604fcc36c4a7 100644 (file)
@@ -3,7 +3,6 @@
 ; CHECK: merge_stores_can
 ; CHECK: callq foo
 ; CHECK: xorps %xmm0, %xmm0
-; CHECK-NEXT: movl 36(%rsp), %ebp
 ; CHECK-NEXT: movups  %xmm0
 ; CHECK: callq foo
 ; CHECK: ret