Skip to content

intrinsic-test: refactor populate_random and related code#2126

Open
davidtwco wants to merge 8 commits into
rust-lang:mainfrom
davidtwco:intrinsic-test-values
Open

intrinsic-test: refactor populate_random and related code#2126
davidtwco wants to merge 8 commits into
rust-lang:mainfrom
davidtwco:intrinsic-test-values

Conversation

@davidtwco
Copy link
Copy Markdown
Member

Each commit has an explanation of what it is trying to do - this PR largely aims to refactor and tidy-up the populate_random function and the related code around it to be more understandable. It also means that this logic should support SVE.

davidtwco added 8 commits May 20, 2026 15:17
The arithmetic for computing the length of the array containing test
values is repeated in a handful of locations and doesn't support scalable
vectors - this commit introduces a `test_values_array_length` helper to
deduplicate this logic.
This function is more complex than it needs to be and `populate_random`
is an unintuitive name - it doesn't do anything involving randomness.
Move this function to the `values` module alongside the other functions
related to generation of the test value arrays and rename with a similar
name.
`PASSES` is a constant accessible to all of the `common` module but is
sometimes used directly and sometimes threaded through functions as an
argument - this commit eliminates the inconsistency and just uses the
constant everywhere.
Given that these "values" are sometimes re-interpreted as negative
numbers, in practice they are bit patterns rather than values.
When SVE vectors start being tested, the test vectors will have length
`$max_sve_bits / $ty_bit_length`, which is longer than most existing
vector types, so more values are useful.
This isn't strictly optimal as it means that the 5/6/7 bit cases are less
likely to be tested with values at the edges (e.g. `0x7e` for 7 bits).
This function doesn't really generate an argument at all, it writes a
static that is eventually loaded from to become the argument.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 20, 2026

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Amanieu, @adamgemmell, @davidtwco, @folkertdev, @sayantn
  • @Amanieu, @adamgemmell, @davidtwco, @folkertdev, @sayantn expanded to Amanieu, adamgemmell, davidtwco, folkertdev, sayantn
  • Random selection from Amanieu, adamgemmell, folkertdev, sayantn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants