[PATCH] D82453: [CostModel] Fix for cast crash
Daniil Fukalov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 24 14:40:28 PDT 2020
dfukalov added inline comments.
================
Comment at: llvm/lib/Analysis/TargetTransformInfo.cpp:1055-1062
// Check that the next levels binary operation exists and matches with the
// current one.
- if (Level + 1 != NumLevels) {
+ if (Level + 1 != NumLevels && isa<Instruction>(NextLevelOp)) {
Optional<TTI::ReductionData> NextLevelRD =
getReductionData(cast<Instruction>(NextLevelOp));
if (!NextLevelRD || !RD->hasSameData(*NextLevelRD))
return TTI::RK_None;
----------------
It seems in case `!isa<Instruction>(NextLevelOp)` we should return `TTI::RK_None` just like for `!NextLevelRD` case. Correct me if I'm wrong.
================
Comment at: llvm/lib/Analysis/TargetTransformInfo.cpp:1079-1082
+ if (isa<Instruction>(NextLevelOp))
+ return matchPairwiseReductionAtLevel(cast<Instruction>(NextLevelOp), Level,
+ NumLevels);
+ return TTI::RK_None;
----------------
You can just replace `cast` to `dyn_cast` here since this recursive call will return `TTI::RK_None` for nullptr as first parameter.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82453/new/
https://reviews.llvm.org/D82453
More information about the llvm-commits
mailing list