-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use an interpreter in MIR jump threading #119461
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
fe988c2
to
a0be45d
Compare
☔ The latest upstream changes (presumably #119675) made this pull request unmergeable. Please resolve the merge conflicts. |
ebbf7b7
to
6f7941e
Compare
6f7941e
to
7012209
Compare
7012209
to
e72b2b1
Compare
@bors r+ |
Rollup of 8 pull requests Successful merges: - rust-lang#116090 (Implement strict integer operations that panic on overflow) - rust-lang#118811 (Use `bool` instead of `PartiolOrd` as return value of the comparison closure in `{slice,Iteraotr}::is_sorted_by`) - rust-lang#119081 (Add Ipv6Addr::is_ipv4_mapped) - rust-lang#119461 (Use an interpreter in MIR jump threading) - rust-lang#119996 (Move OS String implementation into `sys`) - rust-lang#120015 (coverage: Format all coverage tests with `rustfmt`) - rust-lang#120027 (pattern_analysis: Remove `Ty: Copy` bound) - rust-lang#120084 (fix(rust-analyzer): use new pkgid spec to compare) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119461 - cjgillot:jump-threading-interp, r=tmiasko Use an interpreter in MIR jump threading This allows to understand assignments of aggregate constants. This case appears more frequently with GVN promoting aggregates to constants.
BinOp::Ne => ScalarInt::FALSE, | ||
_ => return None, | ||
}; | ||
let value = value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes little sense. If you want to evaluate the constant, call eval
, not normalize
. normalize
is only meant for when you want to keep this around as a mir::Const
but for some reason you want to be sure that if it can evaluated, it is a value (but if it cannot be evaluated that's okay, too). It's a pretty strange operation that should be rarely needed.
This allows to understand assignments of aggregate constants. This case appears more frequently with GVN promoting aggregates to constants.