[PATCH] D146998: [RISCV] Replace an 'else if' with 'else'+assert.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 13:10:31 PDT 2023


craig.topper created this revision.
craig.topper added reviewers: luke, reames.
Herald added subscribers: jobnoorman, VincentWu, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

There are only two cases here. Using an assert ensures there is
no handled third case.

Also move comment to avoid odd formatting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146998

Files:
  llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp


Index: llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
@@ -173,12 +173,12 @@
 
   Builder.SetInsertPoint(BO);
   Builder.SetCurrentDebugLocation(DebugLoc());
-  // Add the splat value to the start
+  // Add the splat value to the start or multiply the start and stride by the
+  // splat.
   if (BO->getOpcode() == Instruction::Add) {
     Start = Builder.CreateAdd(Start, Splat);
-  }
-  // Or multiply the start and stride by the splat.
-  else if (BO->getOpcode() == Instruction::Mul) {
+  } else {
+    assert(BO->getOpcode() == Instruction::Mul && "Unexpected opcode");
     Start = Builder.CreateMul(Start, Splat);
     Stride = Builder.CreateMul(Stride, Splat);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146998.508771.patch
Type: text/x-patch
Size: 861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230327/5aaca793/attachment.bin>


More information about the llvm-commits mailing list