[PATCH] Allow creating truncstores if custom

Matt Arsenault Matthew.Arsenault at amd.com
Tue May 20 13:50:30 PDT 2014


I want to be able to custom lower some stores to illegal types, but currently the truncstore isn't created unless it is legal

http://reviews.llvm.org/D3852

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Index: include/llvm/Target/TargetLowering.h
===================================================================
--- include/llvm/Target/TargetLowering.h
+++ include/llvm/Target/TargetLowering.h
@@ -532,6 +532,15 @@
       getTruncStoreAction(ValVT.getSimpleVT(), MemVT.getSimpleVT()) == Legal;
   }
 
+  bool isTruncStoreLegalOrCustom(EVT ValVT, EVT MemVT) const {
+    if (!isTypeLegal(ValVT) || !MemVT.isSimple())
+      return false;
+
+    LegalizeAction Action = getTruncStoreAction(ValVT.getSimpleVT(),
+                                                MemVT.getSimpleVT());
+    return Action == Legal || Action == Custom;
+  }
+
   /// Return how the indexed load should be treated: either it is legal, needs
   /// to be promoted to a larger size, needs to be expanded to some other code
   /// sequence, or the target has a custom expander for it.
Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9618,8 +9618,8 @@
   // truncating store.  We can do this even if this is already a truncstore.
   if ((Value.getOpcode() == ISD::FP_ROUND || Value.getOpcode() == ISD::TRUNCATE)
       && Value.getNode()->hasOneUse() && ST->isUnindexed() &&
-      TLI.isTruncStoreLegal(Value.getOperand(0).getValueType(),
-                            ST->getMemoryVT())) {
+      TLI.isTruncStoreLegalOrCustom(Value.getOperand(0).getValueType(),
+                                    ST->getMemoryVT())) {
     return DAG.getTruncStore(Chain, SDLoc(N), Value.getOperand(0),
                              Ptr, ST->getMemoryVT(), ST->getMemOperand());
   }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3852.9639.patch
Type: text/x-patch
Size: 1705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140520/99dbe131/attachment.bin>


More information about the llvm-commits mailing list