[PATCH] Allow creating truncstores if custom
Tom Stellard
tom at stellard.net
Mon Jun 9 18:20:47 PDT 2014
On Tue, May 20, 2014 at 08:50:30PM +0000, Matt Arsenault wrote:
> 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())) {
When the DAGCombiner is running after legalization, then I think we only
want to create legal TruncStore's here.
-Tom
> return DAG.getTruncStore(Chain, SDLoc(N), Value.getOperand(0),
> Ptr, ST->getMemoryVT(), ST->getMemOperand());
> }
> 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());
> }
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list