diff --git a/lib/transforms/inst_simplify.cc b/lib/transforms/inst_simplify.cc index 680262974..3b3e75e68 100644 --- a/lib/transforms/inst_simplify.cc +++ b/lib/transforms/inst_simplify.cc @@ -2324,9 +2324,10 @@ std::pair InstSimplify::RunOnInstruction(SliceInst* inst) { std::vector size_adj(dim); bool new_size = false; for (int i = 0; i != dim; ++i) { - int size_i = c_size->GetDataAsInt64(i); - if (size_i == -1) { - size_adj[i] = dst_type.GetNumOfElementsInDim(i); + int64_t size_i = c_size->GetDataAsInt64(i); + int64_t s = dst_type.GetNumOfElementsInDim(i); + if (size_i == -1 && s != -1) { + size_adj[i] = s; new_size = true; } else { size_adj[i] = size_i;