Skip to content

mips: set llvm_args -mno-check-zero-division for all mips targets#157873

Open
xry111 wants to merge 1 commit into
rust-lang:mainfrom
xry111:mips-no-div-by-zero-trap
Open

mips: set llvm_args -mno-check-zero-division for all mips targets#157873
xry111 wants to merge 1 commit into
rust-lang:mainfrom
xry111:mips-no-div-by-zero-trap

Conversation

@xry111

@xry111 xry111 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

In rust interger divide by zero is defined to panic, thus the inserted conditional trap should never trigger as the program should have panicked if the divisor is zero.

So disable the insertion of the redundant conditional trap.

In rust interger divide by zero is defined to panic, thus the inserted
conditional trap should never trigger as the program should have
panicked if the divisor is zero.

So disable the insertion of the redundant conditional trap.
@rustbot

rustbot commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

These commits modify compiler targets.
(See the Target Tier Policy.)

@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 13, 2026
@rustbot

rustbot commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

r? @tiif

rustbot has assigned @tiif.
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: compiler
  • compiler expanded to 73 candidates
  • Random selection from 22 candidates

@folkertdev

Copy link
Copy Markdown
Contributor

Specifically https://doc.rust-lang.org/reference/expressions/operator-expr.html#r-expr.arith-logic.behavior documents:

† For integer types, division by zero panics.

Adding the flag does in fact have an effect on codegen (I'd have assumed that LLVM would be able to spot this, but I guess not)

https://rust.godbolt.org/z/evacM46bM

It's probably a good idea to capture that in an assembly-llvm codegen test using minicore

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants