[llvm] [SLP] NFC. Use InstructionsState::valid if users just want to know whether VL has same opcode. (PR #120217)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 26 10:30:44 PST 2024
================
@@ -8144,9 +8147,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
// Don't handle scalable vectors
- if (S.getOpcode() == Instruction::ExtractElement &&
- isa<ScalableVectorType>(
- cast<ExtractElementInst>(S.getMainOp())->getVectorOperandType())) {
+ if (auto *EE = dyn_cast_if_present<ExtractElementInst>(S.getMainOp());
----------------
alexey-bataev wrote:
1. I.e. the original code check if S is valid, has the opcode ExtractElement and then checks the vector type. getMainOp will crash, if S is invalid. If S is valid, getMainOp cannot return nullptr. dyn_cast_if_present should be used here, just a dyn_cast should be enough. getMainOp just cannot return nullptr.
2. It should be fixed, need to replace by `S and isa<....>(S.getMainOp())`. It worked before, currently it will crash, if S is invalid
https://github.com/llvm/llvm-project/pull/120217
More information about the llvm-commits
mailing list