Merge "Fix segfault with sparse encoding" into sc-v2-dev