aboutsummaryrefslogtreecommitdiff
path: root/source/opt/reduce_load_size.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/reduce_load_size.cpp')
-rw-r--r--source/opt/reduce_load_size.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/opt/reduce_load_size.cpp b/source/opt/reduce_load_size.cpp
index e9b80874..56491b2f 100644
--- a/source/opt/reduce_load_size.cpp
+++ b/source/opt/reduce_load_size.cpp
@@ -161,8 +161,15 @@ bool ReduceLoadSize::ShouldReplaceExtract(Instruction* inst) {
case analysis::Type::kArray: {
const analysis::Constant* size_const =
const_mgr->FindDeclaredConstant(load_type->AsArray()->LengthId());
- assert(size_const->AsIntConstant());
- total_size = size_const->GetU32();
+
+ if (size_const) {
+ assert(size_const->AsIntConstant());
+ total_size = size_const->GetU32();
+ } else {
+ // The size is spec constant, so it is unknown at this time. Assume
+ // it is very large.
+ total_size = UINT32_MAX;
+ }
} break;
case analysis::Type::kStruct:
total_size = static_cast<uint32_t>(