[llvm] 8e985e3 - [RISCV] Replace an 'else if' with 'else'+assert. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 27 13:48:24 PDT 2023
Author: Craig Topper
Date: 2023-03-27T13:48:06-07:00
New Revision: 8e985e3604c4790a1ab5ef2dd6f0a8f56679f32a
URL: https://github.com/llvm/llvm-project/commit/8e985e3604c4790a1ab5ef2dd6f0a8f56679f32a
DIFF: https://github.com/llvm/llvm-project/commit/8e985e3604c4790a1ab5ef2dd6f0a8f56679f32a.diff
LOG: [RISCV] Replace an 'else if' with 'else'+assert. NFC
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
Added:
Modified:
llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
index b1171dac6a09..7e7b25d43de5 100644
--- a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
@@ -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);
}
More information about the llvm-commits
mailing list