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()); }