Skip to content

Extend cast lowering coverage - #347

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:test/extend-mir-cast-lowering-coverage
Jul 20, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:test/extend-mir-cast-lowering-coverage

Conversation

@uurl

@uurl uurl commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up coverage related to #303; this PR does not close that issue because
its listed acceptance cases already landed independently on main.

Summary

Adds focused unit coverage for existing MIR cast lowering paths:

  • same-width integer casts to llvm.bitcast;
  • signed integer-to-float casts to llvm.sitofp;
  • unsigned float-to-integer casts through llvm_fptoui_sat_*;
  • float widening and narrowing through llvm.fpext / llvm.fptrunc;
  • pointer-with-exposed-provenance casts to llvm.inttoptr;
  • cross-address-space pointer casts to llvm.addrspacecast with the destination
    address space checked.

Every route asserts exactly one expected operation and no residual mir.cast.
The saturating paths also check the exact direct callee and declaration.

Maintainer verification

  • cargo fmt --all -- --check
  • Focused cast tests — 13 passed
  • Full mir-lower suite — 135 passed; 7 doctests ignored
  • Library clippy with warnings denied — passed
  • All-target clippy still reports ten pre-existing warnings in unchanged
    tests/lowering_test.rs; this PR introduces none.

Test coverage only; no production lowering behavior changes.

Signed-off-by: Raul Estrada <[email protected]>
@nihalpasham nihalpasham added QoL-improvement Quality-of-life improvement; not a correctness fix IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) tests Adds or improves test coverage labels Jul 20, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Thanks for the PR. LGTM.

I kept the change as submitted. The tests add direct coverage for seven MIR cast routes and verify both the expected LLVM operation and the removal of the original mir.cast.

For example, an i32 -> f32 cast must produce llvm.sitofp, not leave an unresolved MIR cast behind.

Reviewer note: The focused tests and complete mir-lower suite passed. #303 is related, but its acceptance cases were already implemented by earlier PRs, so this PR does not close it.

@nihalpasham
nihalpasham merged commit 376b872 into NVIDIA:main Jul 20, 2026
28 checks passed
@uurl
uurl deleted the test/extend-mir-cast-lowering-coverage branch July 20, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) QoL-improvement Quality-of-life improvement; not a correctness fix tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants