xls icon indicating copy to clipboard operation
xls copied to clipboard

Define semantics for out-of-bounds array accesses in IR

Open meheff opened this issue 4 years ago • 1 comments

Out-of-bounds ArrayIndex operations clamp the index to the highest element: https://github.com/google/xls/blob/ec980d843016e7b7257aeedc4fffd06d8198aa3b/xls/ir/ir_interpreter.cc#L256

Out-of-bounds ArrayUpdate operations are noops: https://github.com/google/xls/blob/ec980d843016e7b7257aeedc4fffd06d8198aa3b/xls/ir/ir_interpreter.cc#L268

This is not very consistent because we clamp only in the ArrayIndex case. We should think about what semantics we want here. One option is to make OOB ArrayIndex return the zero value. Alternatively OOB behavior could be configurable.

meheff avatar Jun 16 '20 14:06 meheff

@meheff I think we've probably reached a stable state on this one, even if we've talked about alternatives -- want to summarize so we can close this out?

cdleary avatar May 10 '22 19:05 cdleary