Skip to content

Commit 72ffa79

Browse files
authored
[NVPTX] tryStoreParam - remove default-only switch statement. NFC. (#145948)
#145581 removed all the remaining special cases from the switch statement leaving just the default, which MSVC complains about.
1 parent 70233c6 commit 72ffa79

File tree

1 file changed

+46
-51
lines changed

1 file changed

+46
-51
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,62 +1713,57 @@ bool NVPTXDAGToDAGISel::tryStoreParam(SDNode *N) {
17131713
// If we have an i1, use an 8-bit store. The lowering code in
17141714
// NVPTXISelLowering will have already emitted an upcast.
17151715
std::optional<unsigned> Opcode;
1716-
switch (N->getOpcode()) {
1716+
switch (NumElts) {
17171717
default:
1718-
switch (NumElts) {
1719-
default:
1720-
llvm_unreachable("Unexpected NumElts");
1721-
case 1: {
1722-
MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
1723-
SDValue Imm = Ops[0];
1724-
if (MemTy != MVT::f16 && MemTy != MVT::bf16 &&
1725-
(isa<ConstantSDNode>(Imm) || isa<ConstantFPSDNode>(Imm))) {
1726-
// Convert immediate to target constant
1727-
if (MemTy == MVT::f32 || MemTy == MVT::f64) {
1728-
const ConstantFPSDNode *ConstImm = cast<ConstantFPSDNode>(Imm);
1729-
const ConstantFP *CF = ConstImm->getConstantFPValue();
1730-
Imm = CurDAG->getTargetConstantFP(*CF, DL, Imm->getValueType(0));
1731-
} else {
1732-
const ConstantSDNode *ConstImm = cast<ConstantSDNode>(Imm);
1733-
const ConstantInt *CI = ConstImm->getConstantIntValue();
1734-
Imm = CurDAG->getTargetConstant(*CI, DL, Imm->getValueType(0));
1735-
}
1736-
Ops[0] = Imm;
1737-
// Use immediate version of store param
1738-
Opcode = pickOpcodeForVT(MemTy, NVPTX::StoreParamI8_i,
1739-
NVPTX::StoreParamI16_i, NVPTX::StoreParamI32_i,
1740-
NVPTX::StoreParamI64_i);
1741-
} else
1742-
Opcode =
1743-
pickOpcodeForVT(Mem->getMemoryVT().getSimpleVT().SimpleTy,
1744-
NVPTX::StoreParamI8_r, NVPTX::StoreParamI16_r,
1745-
NVPTX::StoreParamI32_r, NVPTX::StoreParamI64_r);
1746-
if (Opcode == NVPTX::StoreParamI8_r) {
1747-
// Fine tune the opcode depending on the size of the operand.
1748-
// This helps to avoid creating redundant COPY instructions in
1749-
// InstrEmitter::AddRegisterOperand().
1750-
switch (Ops[0].getSimpleValueType().SimpleTy) {
1751-
default:
1752-
break;
1753-
case MVT::i32:
1754-
Opcode = NVPTX::StoreParamI8TruncI32_r;
1755-
break;
1756-
case MVT::i64:
1757-
Opcode = NVPTX::StoreParamI8TruncI64_r;
1758-
break;
1759-
}
1718+
llvm_unreachable("Unexpected NumElts");
1719+
case 1: {
1720+
MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
1721+
SDValue Imm = Ops[0];
1722+
if (MemTy != MVT::f16 && MemTy != MVT::bf16 &&
1723+
(isa<ConstantSDNode>(Imm) || isa<ConstantFPSDNode>(Imm))) {
1724+
// Convert immediate to target constant
1725+
if (MemTy == MVT::f32 || MemTy == MVT::f64) {
1726+
const ConstantFPSDNode *ConstImm = cast<ConstantFPSDNode>(Imm);
1727+
const ConstantFP *CF = ConstImm->getConstantFPValue();
1728+
Imm = CurDAG->getTargetConstantFP(*CF, DL, Imm->getValueType(0));
1729+
} else {
1730+
const ConstantSDNode *ConstImm = cast<ConstantSDNode>(Imm);
1731+
const ConstantInt *CI = ConstImm->getConstantIntValue();
1732+
Imm = CurDAG->getTargetConstant(*CI, DL, Imm->getValueType(0));
1733+
}
1734+
Ops[0] = Imm;
1735+
// Use immediate version of store param
1736+
Opcode =
1737+
pickOpcodeForVT(MemTy, NVPTX::StoreParamI8_i, NVPTX::StoreParamI16_i,
1738+
NVPTX::StoreParamI32_i, NVPTX::StoreParamI64_i);
1739+
} else
1740+
Opcode = pickOpcodeForVT(Mem->getMemoryVT().getSimpleVT().SimpleTy,
1741+
NVPTX::StoreParamI8_r, NVPTX::StoreParamI16_r,
1742+
NVPTX::StoreParamI32_r, NVPTX::StoreParamI64_r);
1743+
if (Opcode == NVPTX::StoreParamI8_r) {
1744+
// Fine tune the opcode depending on the size of the operand.
1745+
// This helps to avoid creating redundant COPY instructions in
1746+
// InstrEmitter::AddRegisterOperand().
1747+
switch (Ops[0].getSimpleValueType().SimpleTy) {
1748+
default:
1749+
break;
1750+
case MVT::i32:
1751+
Opcode = NVPTX::StoreParamI8TruncI32_r;
1752+
break;
1753+
case MVT::i64:
1754+
Opcode = NVPTX::StoreParamI8TruncI64_r;
1755+
break;
17601756
}
1761-
break;
1762-
}
1763-
case 2:
1764-
case 4: {
1765-
MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
1766-
Opcode = pickOpcodeForVectorStParam(Ops, NumElts, MemTy, CurDAG, DL);
1767-
break;
1768-
}
17691757
}
17701758
break;
17711759
}
1760+
case 2:
1761+
case 4: {
1762+
MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
1763+
Opcode = pickOpcodeForVectorStParam(Ops, NumElts, MemTy, CurDAG, DL);
1764+
break;
1765+
}
1766+
}
17721767

17731768
SDVTList RetVTs = CurDAG->getVTList(MVT::Other, MVT::Glue);
17741769
SDNode *Ret = CurDAG->getMachineNode(*Opcode, DL, RetVTs, Ops);

0 commit comments

Comments
 (0)