Skip to content

[LangRef] Update the semantic of experimental.get.vector.length #104475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19634,7 +19634,7 @@ vectorization factor should be multiplied by vscale.
Semantics:
""""""""""

Returns a positive i32 value (explicit vector length) that is unknown at compile
Returns a non-negative i32 value (explicit vector length) that is unknown at compile
time and depends on the hardware specification.
If the result value does not fit in the result type, then the result is
a :ref:`poison value <poisonvalues>`.
Expand All @@ -19644,13 +19644,23 @@ in order to get the number of elements to process on each loop iteration. The
result should be used to decrease the count for the next iteration until the
count reaches zero.

If the count is larger than the number of lanes in the type described by the
last 2 arguments, this intrinsic may return a value less than the number of
lanes implied by the type. The result will be at least as large as the result
will be on any later loop iteration.
Let ``%max_lanes`` be the number of lanes in the type described by ``%vf`` and
``%scalable``, here are the constraints on the returned value:

This intrinsic will only return 0 if the input count is also 0. A non-zero input
count will produce a non-zero result.
- If ``%cnt`` equals to 0, returns 0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably say "less than or equal to"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fixed now.

- The returned value is always less than or equal to ``%max_lanes``.
- The returned value is always greater than or equal to ``ceil(%cnt / ceil(%cnt / %max_lanes))``,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The returned value is always greater than or equal to ``ceil(%cnt / ceil(%cnt / %max_lanes))``.
- The returned value is always greater than or equal to ``ceil(%cnt / ceil(%cnt / %max_lanes))``, if ``%cnt`` is non-zero.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if ``%cnt`` is non-zero.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The returned values decrease monotonically in each loop iteration. That is,
- The returned values are monotonically non-increasing in each loop iteration. That is,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

- The returned values are monotonically non-increasing in each loop iteration. That is,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the returned value of a iteration is at least as large as that of any later
the returned value of an iteration is at least as large as that of any later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

the returned value of an iteration is at least as large as that of any later
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
iterations.
iteration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

iteration.

Note that it has the following implications:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The number of iterations is equal to ``ceil(%cnt / %max_lanes)``.

right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, though since the %cnt value is decreased in every iteration, I phrase it slightly differently now.


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- If ``%cnt`` is non-zero, the result should be non-zero as well.
- If ``%cnt`` is non-zero, the return value is non-zero as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

- For a loop that uses this intrinsic, the number of iterations is equal to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- If ``%cnt`` is less than ``%max_lanes``, it has to return ``%cnt``.
- If ``%cnt`` is less than or equal to ``%max_lanes``, the return value is equal to ``%cnt``.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

``ceil(%C / %max_lanes)`` where ``%C`` is the initial ``%cnt`` value.
- If ``%cnt`` is non-zero, the return value is non-zero as well.
- If ``%cnt`` is less than or equal to ``%max_lanes``, the return value is equal to ``%cnt``.

'``llvm.experimental.vector.partial.reduce.add.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading