[llvm] 72ffa79 - [NVPTX] tryStoreParam - remove default-only switch statement. NFC. (#145948)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 26 12:13:07 PDT 2025
Author: Simon Pilgrim
Date: 2025-06-26T20:13:04+01:00
New Revision: 72ffa799c847058df15ad9e03d34e6a6ad5abee0
URL: https://github.com/llvm/llvm-project/commit/72ffa799c847058df15ad9e03d34e6a6ad5abee0
DIFF: https://github.com/llvm/llvm-project/commit/72ffa799c847058df15ad9e03d34e6a6ad5abee0.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
index 5ee1bee49247c..7c1d13119fa18 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
@@ -1713,62 +1713,57 @@ bool NVPTXDAGToDAGISel::tryStoreParam(SDNode *N) {
// If we have an i1, use an 8-bit store. The lowering code in
// NVPTXISelLowering will have already emitted an upcast.
std::optional<unsigned> Opcode;
- switch (N->getOpcode()) {
+ switch (NumElts) {
default:
- switch (NumElts) {
- default:
- llvm_unreachable("Unexpected NumElts");
- case 1: {
- MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
- SDValue Imm = Ops[0];
- if (MemTy != MVT::f16 && MemTy != MVT::bf16 &&
- (isa<ConstantSDNode>(Imm) || isa<ConstantFPSDNode>(Imm))) {
- // Convert immediate to target constant
- if (MemTy == MVT::f32 || MemTy == MVT::f64) {
- const ConstantFPSDNode *ConstImm = cast<ConstantFPSDNode>(Imm);
- const ConstantFP *CF = ConstImm->getConstantFPValue();
- Imm = CurDAG->getTargetConstantFP(*CF, DL, Imm->getValueType(0));
- } else {
- const ConstantSDNode *ConstImm = cast<ConstantSDNode>(Imm);
- const ConstantInt *CI = ConstImm->getConstantIntValue();
- Imm = CurDAG->getTargetConstant(*CI, DL, Imm->getValueType(0));
- }
- Ops[0] = Imm;
- // Use immediate version of store param
- Opcode = pickOpcodeForVT(MemTy, NVPTX::StoreParamI8_i,
- NVPTX::StoreParamI16_i, NVPTX::StoreParamI32_i,
- NVPTX::StoreParamI64_i);
- } else
- Opcode =
- pickOpcodeForVT(Mem->getMemoryVT().getSimpleVT().SimpleTy,
- NVPTX::StoreParamI8_r, NVPTX::StoreParamI16_r,
- NVPTX::StoreParamI32_r, NVPTX::StoreParamI64_r);
- if (Opcode == NVPTX::StoreParamI8_r) {
- // Fine tune the opcode depending on the size of the operand.
- // This helps to avoid creating redundant COPY instructions in
- // InstrEmitter::AddRegisterOperand().
- switch (Ops[0].getSimpleValueType().SimpleTy) {
- default:
- break;
- case MVT::i32:
- Opcode = NVPTX::StoreParamI8TruncI32_r;
- break;
- case MVT::i64:
- Opcode = NVPTX::StoreParamI8TruncI64_r;
- break;
- }
+ llvm_unreachable("Unexpected NumElts");
+ case 1: {
+ MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
+ SDValue Imm = Ops[0];
+ if (MemTy != MVT::f16 && MemTy != MVT::bf16 &&
+ (isa<ConstantSDNode>(Imm) || isa<ConstantFPSDNode>(Imm))) {
+ // Convert immediate to target constant
+ if (MemTy == MVT::f32 || MemTy == MVT::f64) {
+ const ConstantFPSDNode *ConstImm = cast<ConstantFPSDNode>(Imm);
+ const ConstantFP *CF = ConstImm->getConstantFPValue();
+ Imm = CurDAG->getTargetConstantFP(*CF, DL, Imm->getValueType(0));
+ } else {
+ const ConstantSDNode *ConstImm = cast<ConstantSDNode>(Imm);
+ const ConstantInt *CI = ConstImm->getConstantIntValue();
+ Imm = CurDAG->getTargetConstant(*CI, DL, Imm->getValueType(0));
+ }
+ Ops[0] = Imm;
+ // Use immediate version of store param
+ Opcode =
+ pickOpcodeForVT(MemTy, NVPTX::StoreParamI8_i, NVPTX::StoreParamI16_i,
+ NVPTX::StoreParamI32_i, NVPTX::StoreParamI64_i);
+ } else
+ Opcode = pickOpcodeForVT(Mem->getMemoryVT().getSimpleVT().SimpleTy,
+ NVPTX::StoreParamI8_r, NVPTX::StoreParamI16_r,
+ NVPTX::StoreParamI32_r, NVPTX::StoreParamI64_r);
+ if (Opcode == NVPTX::StoreParamI8_r) {
+ // Fine tune the opcode depending on the size of the operand.
+ // This helps to avoid creating redundant COPY instructions in
+ // InstrEmitter::AddRegisterOperand().
+ switch (Ops[0].getSimpleValueType().SimpleTy) {
+ default:
+ break;
+ case MVT::i32:
+ Opcode = NVPTX::StoreParamI8TruncI32_r;
+ break;
+ case MVT::i64:
+ Opcode = NVPTX::StoreParamI8TruncI64_r;
+ break;
}
- break;
- }
- case 2:
- case 4: {
- MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
- Opcode = pickOpcodeForVectorStParam(Ops, NumElts, MemTy, CurDAG, DL);
- break;
- }
}
break;
}
+ case 2:
+ case 4: {
+ MVT::SimpleValueType MemTy = Mem->getMemoryVT().getSimpleVT().SimpleTy;
+ Opcode = pickOpcodeForVectorStParam(Ops, NumElts, MemTy, CurDAG, DL);
+ break;
+ }
+ }
SDVTList RetVTs = CurDAG->getVTList(MVT::Other, MVT::Glue);
SDNode *Ret = CurDAG->getMachineNode(*Opcode, DL, RetVTs, Ops);
More information about the llvm-commits
mailing list