Skip to content

[mlir][vector] Update how OOB accesses are handled by vector.extract/vector.insert #137147

Open
@banach-space

Description

@banach-space

At the moment, only -1 is used to "model" poison values - i.e., accesses that produce poison:

  %c_neg_1 = arith.constant -1 : index
  %0 = vector.insert %value_to_store, %dest[%c_neg_1] : vector<5xf32> into vector<4x5xf32>
  %1 = vector.extract %src[%c_neg_1, 0] : f32 from vector<4x5xf32>

From the discussion so far, it seems that:

  • We should treat any out-of-bounds (OOB) index — not just -1 — as producing a poison value (see @dcaballe’s supportive comment).
  • We should allow using %poison = ub.poison : index directly as an index that generates poison.

This direction would bring the dialect more in line with LLVM semantics. From LLVM LangRef:

If idx exceeds the length of val for a fixed-length vector, the result is a poison value

VOICES AGAINST / CONCERNS

We should be mindful of @kuhar’s comment. While not opposed to the proposed direction:

If others would prefer consistency with the LLVM instructions, I won't object.

... we should keep him in the loop and ensure any concerns he raises are addressed.

PRIOR DISCUSSION

Relevant context and discussion can be found in:

Also, this issue is to track NEXT STEPS from this comment.

CC @dcaballe @math-fehr @kuhar

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions