summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/R600/SIISelLowering.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Target/R600/SIISelLowering.cpp b/llvm/lib/Target/R600/SIISelLowering.cpp
index be42ceb52d9..1a73d9bda58 100644
--- a/llvm/lib/Target/R600/SIISelLowering.cpp
+++ b/llvm/lib/Target/R600/SIISelLowering.cpp
@@ -1920,6 +1920,30 @@ void SITargetLowering::adjustWritemask(MachineSDNode *&Node,
}
}
+/// \brief Legalize INSERT_SUBREG instructions with frame index operands.
+/// LLVM assumes that all INSERT_SUBREG inputs are registers.
+static void legalizeInsertSubreg(MachineSDNode *InsertSubreg,
+ SelectionDAG &DAG) {
+
+ assert(InsertSubreg->getMachineOpcode() == AMDGPU::INSERT_SUBREG);
+
+ SmallVector<SDValue, 8> Ops;
+ for (unsigned i = 0; i < 2; ++i) {
+ if (!isa<FrameIndexSDNode>(InsertSubreg->getOperand(i))) {
+ Ops.push_back(InsertSubreg->getOperand(i));
+ continue;
+ }
+
+ SDLoc DL(InsertSubreg);
+ Ops.push_back(SDValue(DAG.getMachineNode(AMDGPU::S_MOV_B32, DL,
+ InsertSubreg->getOperand(i).getValueType(),
+ InsertSubreg->getOperand(i)), 0));
+ }
+
+ DAG.UpdateNodeOperands(InsertSubreg, Ops[0], Ops[1],
+ InsertSubreg->getOperand(2));
+}
+
/// \brief Fold the instructions after selecting them.
SDNode *SITargetLowering::PostISelFolding(MachineSDNode *Node,
SelectionDAG &DAG) const {
@@ -1930,6 +1954,11 @@ SDNode *SITargetLowering::PostISelFolding(MachineSDNode *Node,
if (TII->isMIMG(Node->getMachineOpcode()))
adjustWritemask(Node, DAG);
+ if (Node->getMachineOpcode() == AMDGPU::INSERT_SUBREG) {
+ legalizeTargetIndependentNode(Node, DAG);
+ return Node;
+ }
+
return legalizeOperands(Node, DAG);
}
OpenPOWER on IntegriCloud