[llvm] [NVPTX] tryStoreParam - remove default-only switch statement. NFC. (PR #145948)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 26 10:58:32 PDT 2025
https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/145948
#145581 remove all the remaining special cases from the switch statement leaving just the default, which MSVC complains about.
>From c0128d876e360923ff66ef9e9aa8116f86fbd80e Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Thu, 26 Jun 2025 18:57:52 +0100
Subject: [PATCH] [NVPTX] tryStoreParam - remove default-only switch statement.
NFC.
#145581 remove all the remaining special cases from the switch statement leaving just the default, which MSVC complains about.
---
llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp | 97 ++++++++++-----------
1 file changed, 46 insertions(+), 51 deletions(-)
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