[RISCV] Replace an 'else if' with 'else'+assert. NFC
authorCraig Topper <craig.topper@sifive.com>
Mon, 27 Mar 2023 20:48:06 +0000 (13:48 -0700)
committerCraig Topper <craig.topper@sifive.com>
Mon, 27 Mar 2023 20:48:06 +0000 (13:48 -0700)
There are only two cases here. Using an assert ensures there is
no handled third case.

Also move comment to avoid odd formatting.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D146998

llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp

index b1171da..7e7b25d 100644 (file)
@@ -173,12 +173,12 @@ static std::pair<Value *, Value *> matchStridedStart(Value *Start,
 
   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);
   }