summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2017-11-28 17:11:30 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2017-11-28 17:11:30 +0000
commite123aba94ead1673e8672e0fdd7ef9a75d1b205c (patch)
tree089efacac012cc2295f85b4fb32126c5ce88bc94 /llvm/lib
parentece5bc358a243fcbc74f92883f37110980b0ac04 (diff)
downloadbcm5719-llvm-e123aba94ead1673e8672e0fdd7ef9a75d1b205c.tar.gz
bcm5719-llvm-e123aba94ead1673e8672e0fdd7ef9a75d1b205c.zip
DAG: Legalize truncstores to illegal int types
Truncate to a legal int type, and produce a new truncstore from a narrower type. llvm-svn: 319185
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 6974e7006ce..fdbd3e1105b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -624,13 +624,23 @@ void SelectionDAGLegalize::LegalizeStoreOps(SDNode *Node) {
assert(!StVT.isVector() &&
"Vector Stores are handled in LegalizeVectorOps");
+ SDValue Result;
+
// TRUNCSTORE:i16 i32 -> STORE i16
- assert(TLI.isTypeLegal(StVT) &&
- "Do not know how to expand this store!");
- Value = DAG.getNode(ISD::TRUNCATE, dl, StVT, Value);
- SDValue Result =
- DAG.getStore(Chain, dl, Value, Ptr, ST->getPointerInfo(),
- Alignment, MMOFlags, AAInfo);
+ if (TLI.isTypeLegal(StVT)) {
+ Value = DAG.getNode(ISD::TRUNCATE, dl, StVT, Value);
+ Result = DAG.getStore(Chain, dl, Value, Ptr, ST->getPointerInfo(),
+ Alignment, MMOFlags, AAInfo);
+ } else {
+ // The in-memory type isn't legal. Truncate to the type it would promote
+ // to, and then do a truncstore.
+ Value = DAG.getNode(ISD::TRUNCATE, dl,
+ TLI.getTypeToTransformTo(*DAG.getContext(), StVT),
+ Value);
+ Result = DAG.getTruncStore(Chain, dl, Value, Ptr, ST->getPointerInfo(),
+ StVT, Alignment, MMOFlags, AAInfo);
+ }
+
ReplaceNode(SDValue(Node, 0), Result);
break;
}
OpenPOWER on IntegriCloud