Skip to content

fix(tests): allow either branch direction in ilog_known_base#158359

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
HNO3Miracle:fix-riscv-ilog-known-base
Jun 26, 2026
Merged

fix(tests): allow either branch direction in ilog_known_base#158359
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
HNO3Miracle:fix-riscv-ilog-known-base

Conversation

@HNO3Miracle

@HNO3Miracle HNO3Miracle commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #158339.

tests/codegen-llvm/ilog_known_base.rs checks that checked_ilog with a known power-of-two base is lowered through the faster llvm.ctlz path.

On riscv64gc-unknown-linux-gnu, LLVM emits the zero check with the opposite branch direction (icmp eq i32 %val, 0) from what the test currently expects (icmp ne i32 %val, 0). Both forms still guard the same llvm.ctlz fast path, so this relaxes the FileCheck pattern to accept either comparison direction.

This also fixes the checked_ilog16 FileCheck variable to use the DIV4 result it just matched.

Tested:

./x test --stage 2 tests/codegen-llvm/ilog_known_base.rs

Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 24, 2026
@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @petrochenkov (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 20 candidates

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e81423a has been approved by petrochenkov

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 25, 2026
…ase, r=petrochenkov

fix(tests): allow either branch direction in ilog_known_base

Fixes rust-lang#158339.

`tests/codegen-llvm/ilog_known_base.rs` checks that `checked_ilog` with a known power-of-two base is lowered through the faster `llvm.ctlz` path.

On `riscv64gc-unknown-linux-gnu`, LLVM emits the zero check with the opposite branch direction (`icmp eq i32 %val, 0`) from what the test currently expects (`icmp ne i32 %val, 0`). Both forms still guard the same `llvm.ctlz` fast path, so this relaxes the FileCheck pattern to accept either comparison direction.

This also fixes the `checked_ilog16` FileCheck variable to use the `DIV4` result it just matched.

Tested:

```sh
./x test --stage 2 tests/codegen-llvm/ilog_known_base.rs
```
rust-bors Bot pushed a commit that referenced this pull request Jun 25, 2026
Rollup of 10 pull requests

Successful merges:

 - #158410 (Update LLVM for Mach-O __LINKEDIT alignment fix.)
 - #157397 (cmse: clear padding when crossing the secure boundary)
 - #158036 (Add -Zinstrument-mcount=fentry to -Zinstrument-mcount)
 - #158330 (llvm: use intrinsics for f16, f32 minimum/maximum)
 - #158359 (fix(tests): allow either branch direction in ilog_known_base)
 - #158067 (LLVM 23: Adapt codegen test to moved assume)
 - #158261 (Move part of the target checking for `#[may_dangle]` to the parser)
 - #158358 (Fix invalid E0609 raw pointer deref suggestion inside macros)
 - #158392 (delegation: add tests for defaults and infers in generics)
 - #158394 (Generate synthetic generic args only for delegation's child segment)
@rust-bors rust-bors Bot merged commit 1f9e9af into rust-lang:main Jun 26, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 26, 2026
rust-timer added a commit that referenced this pull request Jun 26, 2026
Rollup merge of #158359 - HNO3Miracle:fix-riscv-ilog-known-base, r=petrochenkov

fix(tests): allow either branch direction in ilog_known_base

Fixes #158339.

`tests/codegen-llvm/ilog_known_base.rs` checks that `checked_ilog` with a known power-of-two base is lowered through the faster `llvm.ctlz` path.

On `riscv64gc-unknown-linux-gnu`, LLVM emits the zero check with the opposite branch direction (`icmp eq i32 %val, 0`) from what the test currently expects (`icmp ne i32 %val, 0`). Both forms still guard the same `llvm.ctlz` fast path, so this relaxes the FileCheck pattern to accept either comparison direction.

This also fixes the `checked_ilog16` FileCheck variable to use the `DIV4` result it just matched.

Tested:

```sh
./x test --stage 2 tests/codegen-llvm/ilog_known_base.rs
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[riscv64]: FileCheck stderr: tests/codegen-llvm/ilog_known_base.rs error: CHECK: expected string not found in input

3 participants