summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
diff options
context:
space:
mode:
authorAlex Bradbury <asb@lowrisc.org>2018-04-18 19:02:31 +0000
committerAlex Bradbury <asb@lowrisc.org>2018-04-18 19:02:31 +0000
commit099c720426b2e54fc17c8fddc270ea9a8ca2e356 (patch)
tree452bb232a9c6b6ff04f3a0859da68c6ced2a6ecb /llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
parent5832eb4cfd2fcb20fc9f25b9d9bdc2930df3cb27 (diff)
downloadbcm5719-llvm-099c720426b2e54fc17c8fddc270ea9a8ca2e356.tar.gz
bcm5719-llvm-099c720426b2e54fc17c8fddc270ea9a8ca2e356.zip
Revert "[RISCV] implement li pseudo instruction"
Reverts rL330224, while issues with the C extension and missed common subexpression elimination opportunities are addressed. Neither of these issues are visible in current RISC-V backend unit tests, which clearly need expanding. llvm-svn: 330281
Diffstat (limited to 'llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp')
-rw-r--r--llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp65
1 files changed, 22 insertions, 43 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index 8fdf18efb58..630439bb53c 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -179,62 +179,41 @@ void RISCVDAGToDAGISel::doPeepholeLoadStoreADDI() {
SDValue Base = N->getOperand(BaseOpIdx);
- // If the base is an ADDI or PseudoLI, we can either merge it or at least
- // sink the lowest 12 bits into the load/store.
- if (!Base.isMachineOpcode() || (Base.getMachineOpcode() != RISCV::ADDI &&
- Base.getMachineOpcode() != RISCV::PseudoLI))
+ // If the base is an ADDI, we can merge it in to the load/store.
+ if (!Base.isMachineOpcode() || Base.getMachineOpcode() != RISCV::ADDI)
continue;
- SDValue ImmOperand;
- SDValue Parent;
- if (Base.getMachineOpcode() == RISCV::PseudoLI) {
- ImmOperand = Base.getOperand(0);
- auto Const = dyn_cast<ConstantSDNode>(ImmOperand);
- if (!Const || (Const->getSExtValue() & 0xFFF) == 0)
- continue;
-
- int64_t Hi52 = (Const->getSExtValue() + 0x800) & ~0xFFF;
- SDValue HiVal = CurDAG->getTargetConstant(Hi52, SDLoc(ImmOperand),
- ImmOperand.getValueType());
- Parent =
- SDValue(CurDAG->getMachineNode(RISCV::PseudoLI, SDLoc(ImmOperand),
- ImmOperand.getValueType(), HiVal),
- 0);
-
- int64_t Lo12 = SignExtend64<12>(Const->getSExtValue());
- ImmOperand = CurDAG->getTargetConstant(Lo12, SDLoc(ImmOperand),
- ImmOperand.getValueType());
+ SDValue ImmOperand = Base.getOperand(1);
+
+ if (auto Const = dyn_cast<ConstantSDNode>(ImmOperand)) {
+ ImmOperand = CurDAG->getTargetConstant(
+ Const->getSExtValue(), SDLoc(ImmOperand), ImmOperand.getValueType());
+ } else if (auto GA = dyn_cast<GlobalAddressSDNode>(ImmOperand)) {
+ ImmOperand = CurDAG->getTargetGlobalAddress(
+ GA->getGlobal(), SDLoc(ImmOperand), ImmOperand.getValueType(),
+ GA->getOffset(), GA->getTargetFlags());
} else {
- Parent = Base.getOperand(0);
- ImmOperand = Base.getOperand(1);
-
- if (auto Const = dyn_cast<ConstantSDNode>(ImmOperand)) {
- ImmOperand =
- CurDAG->getTargetConstant(Const->getSExtValue(), SDLoc(ImmOperand),
- ImmOperand.getValueType());
- } else if (auto GA = dyn_cast<GlobalAddressSDNode>(ImmOperand)) {
- ImmOperand = CurDAG->getTargetGlobalAddress(
- GA->getGlobal(), SDLoc(ImmOperand), ImmOperand.getValueType(),
- GA->getOffset(), GA->getTargetFlags());
- } else {
- continue;
- }
+ continue;
}
- DEBUG(dbgs() << "Folding add-immediate or PseudoLI into mem-op:\nBase: ");
- DEBUG(Base.dump(CurDAG));
+ DEBUG(dbgs() << "Folding add-immediate into mem-op:\nBase: ");
+ DEBUG(Base->dump(CurDAG));
DEBUG(dbgs() << "\nN: ");
DEBUG(N->dump(CurDAG));
DEBUG(dbgs() << "\n");
// Modify the offset operand of the load/store.
if (BaseOpIdx == 0) // Load
- CurDAG->UpdateNodeOperands(N, Parent, ImmOperand, N->getOperand(2));
+ CurDAG->UpdateNodeOperands(N, Base.getOperand(0), ImmOperand,
+ N->getOperand(2));
else // Store
- CurDAG->UpdateNodeOperands(N, N->getOperand(0), Parent, ImmOperand,
- N->getOperand(3));
+ CurDAG->UpdateNodeOperands(N, N->getOperand(0), Base.getOperand(0),
+ ImmOperand, N->getOperand(3));
+
+ // The add-immediate may now be dead, in which case remove it.
+ if (Base.getNode()->use_empty())
+ CurDAG->RemoveDeadNode(Base.getNode());
}
- CurDAG->RemoveDeadNodes();
}
// Remove redundant BuildPairF64+SplitF64 pairs. i.e. cases where an f64 is
OpenPOWER on IntegriCloud