about summary refs log tree commit diff
path: root/tests/mir-opt/pre-codegen
AgeCommit message (Collapse)AuthorLines
2025-10-02mir-opt: Eliminate dead ref statementsdianqk-369/+1579
2025-09-16Enable DestinationPropagation by default.Camille GILLOT-638/+547
2025-09-07Unify a source with all possible destinations.Camille Gillot-2/+2
2025-08-22Rollup merge of #142185 - saethlin:refprop-moves, r=cjgillotJacob Pratt-41/+41
Convert moves of references to copies in ReferencePropagation This is a fix for https://github.com/rust-lang/rust/issues/141101. The root cause of this miscompile is that the SsaLocals analysis that MIR transforms use is supposed to detect locals that are only written to once, in their single assignment. But that analysis is subtly wrong; it does not consider `Operand::Move` to be a write even though the meaning ascribed to `Operand::Move` (at least as a function parameter) by Miri is that the callee may have done arbitrary writes to the caller's Local that the Operand wraps (because `Move` is pass-by-pointer). So Miri conwiders `Operand::Move` to be a write but both the MIR visitor system considers it a read, and so does SsaLocals. I have tried fixing this by changing the `PlaceContext` that is ascribed to an `Operand::Move` to a `MutatingUseContext` but that seems to have borrow checker implications, and changing SsaLocals seems to have wide-ranging regressions in MIR optimizations. So instead of doing those, this PR adds a new kludge to ReferencePropagation, which follows the same line of thinking as the kludge in CopyProp that solves this same problem inside that pass: https://github.com/rust-lang/rust/blob/a5584a8fe16037dc01782064fa41424a6dbe9987/compiler/rustc_mir_transform/src/copy_prop.rs#L65-L98
2025-08-21Consolidate panicking functions in `slice/index.rs`Karl Meakin-2/+136
Consolidate all the panicking functions in `slice/index.rs` to use a single `slice_index_fail` function, similar to how it is done in `str/traits.rs`.
2025-08-11Convert moves of references to copies in RefPropBen Kimock-41/+41
2025-08-04Rollup merge of #144875 - scottmcm:more-mir-tests, r=cjgillotStuart Cook-0/+403
Add some pre-codegen MIR tests for debug mode No functional changes; just some tests. I made these for rust-lang/rust#144483, but that's going in a different direction, so I wanted to propose we just add them to help see the impact of other related changes in the future. r? mir
2025-08-03Add a debug-mode MIR pre-codegen test for `?`-on-`Option`Scott McMurray-0/+197
2025-08-03Add a mir-opt test for *debug* MIR from `derive(PartialOrd, Ord)`Scott McMurray-0/+206
Because the follow-up commits will affect it, and the goal is to show how.
2025-07-30`AlignmentEnum` should just be `repr(usize)` nowScott McMurray-34/+17
Since it's cfg'd instead of type-aliased
2025-07-28Simplify `align_of_val::<[T]>(…)` → `align_of::<T>()`Scott McMurray-45/+33
2025-07-28Add a mir-opt pre-codegen test for dropping a `Box<[impl Copy]>`Scott McMurray-0/+463
2025-07-26Rollup merge of #144331 - ↵Matthias Krüger-2/+8
jplatte:matches-allow-non_exhaustive_omitted_patterns, r=Nadrieril Disable non_exhaustive_omitted_patterns within matches! macro Closes rust-lang/rust#117304. I believe I can skip all of the bootstrap stuff mentioned in https://github.com/rust-lang/rust/issues/117304#issuecomment-1784414453 due to https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/, right? cc `@Jules-Bertholet`
2025-07-25Update mir-opt expected output for matches! macroJonas Platte-2/+8
2025-07-23Give an AllocId to ConstValue::Slice.Camille GILLOT-4/+18
2025-07-18Rollup merge of #143271 - cjgillot:gvn-types, r=oli-obkMatthias Krüger-4/+1
Store the type of each GVN value MIR is fully typed, so type information is an integral part of what defines a value. GVN currently tries to circumvent storing types, which creates all sorts of complexities. This PR stores the type along with the enum `Value` when defining a value index. This allows to simplify a lot of code. Fixes rust-lang/rust#128094 Fixes rust-lang/rust#135128 r? ``````@ghost`````` for perf
2025-07-14Update SUMMARY.mdfuder.eth-1/+1
Update README.md
2025-07-10Propagate from borrowed locals in CopyPropTomasz Miąsko-112/+80
2025-07-06Do not unify borrowed locals in CopyProp.Camille GILLOT-80/+112
2025-07-01Remove extraneous types.Camille GILLOT-4/+1
2025-06-12intrinsics: rename min_align_of to align_ofRalf Jung-2/+2
2025-05-30`slice.get(i)` should use a slice projection in MIR, like `slice[i]` doesScott McMurray-66/+26
2025-05-21Add some track_caller info to precondition panicsBen Kimock-37/+37
2025-04-21mir-opt: execute MatchBranchSimplification after GVNdianqk-0/+23
This can provide more opportunities for MatchBranchSimplification.
2025-04-04Allow GVN to produce places and not just locals.Camille GILLOT-0/+7
2025-04-03Auto merge of #132527 - DianQK:gvn-stmt-iter, r=oli-obkbors-170/+139
gvn: Invalid dereferences for all non-local mutations Fixes #132353. This PR removes the computation value by traversing SSA locals through `for_each_assignment_mut`. Because the `for_each_assignment_mut` traversal skips statements which have side effects, such as dereference assignments, the computation may be unsound. Instead of `for_each_assignment_mut`, we compute values by traversing in reverse postorder. Because we compute and use the symbolic representation of values on the fly, I invalidate all old values when encountering a dereference assignment. The current approach does not prevent the optimization of a clone to a copy. In the future, we may add an alias model, or dominance information for dereference assignments, or SSA form to help GVN. r? cjgillot cc `@jieyouxu` #132356 cc `@RalfJung` #133474
2025-04-03Remove `unsound-mir-opts` for `simplify_aggregate_to_copy`dianqk-11/+5
2025-04-02Make slice iterator constructors unstably constDaniel Bloom-140/+128
2025-04-02Bless testsdianqk-158/+134
2025-04-02Revert "comment out the old tests instead of adjusting them"dianqk-1/+0
This reverts commit 906f66fb4c22daa8a6f97e5c048e9f6ab3fd9051.
2025-03-23Rollup merge of #138135 - scottmcm:chaining-ord, r=Mark-SimulacrumJacob Pratt-0/+156
Simplify `PartialOrd` on tuples containing primitives We noticed in https://github.com/rust-lang/rust/pull/133984#issuecomment-2704011800 that currently the tuple comparison code, while it [does optimize down](https://github.com/rust-lang/rust/blob/master/tests/codegen/comparison-operators-2-tuple.rs) today, is kinda huge: <https://rust.godbolt.org/z/xqMoeYbhE> This PR changes the tuple code to go through an overridable "chaining" version of the comparison functions, so that for simple things like `(i16, u16)` and `(f32, f32)` (as seen in the new MIR pre-codegen test) we just directly get the ```rust if lhs.0 == rhs.0 { lhs.0 OP rhs.0 } else { lhs.1 OP rhs.1 } ``` version in MIR, rather than emitting a mess for LLVM to have to clean up. Test added in the first commit, so you can see the MIR diff in the second one.
2025-03-23Stop using specialization for thisScott McMurray-2/+2
Uses `__`-named `doc(hidden)` methods instead.
2025-03-19Add chaining versions of lt/le/gt/ge and use them in tuple PartialOrdScott McMurray-314/+72
2025-03-19Add a MIR pre-codegen test for tuple comparisonsScott McMurray-0/+398
We have codegen ones, but it looks like we could make those less flakey by just doing something better in the first place...
2025-03-15Add MIR pre-codegen tests to track 138544Scott McMurray-4/+315
2025-03-12Allow more top-down inlining for single-BB calleesScott McMurray-81/+93
This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
2025-03-05Make `is_le` and friends work like clang'sScott McMurray-12/+27
2025-03-05Also add a MIR pre-codegen test for the derived `PartialOrd::le`Scott McMurray-0/+98
2025-03-03Inline FnOnce once againMichael Goulet-1/+5
2025-02-14Go back to `Some` instead of transmuting to it.Scott McMurray-163/+204
This adds a few more statements to `next`, but optimizes better in the loops (saving 2 blocks in `forward_loop`, for example)
2025-02-14Save another BB by using `SubUnchecked` instead of a call to `arith_offset`Scott McMurray-315/+251
Probably reasonable anyway since it more obviously drops provenance.
2025-02-14Simplify `slice::Iter::next` enough that it inlinesScott McMurray-140/+751
2025-02-12`transmute` should also assume non-null pointersScott McMurray-64/+52
Previously it only did integer-ABI things, but this way it does data pointers too. That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-10Auto merge of #135701 - calebzulawski:sync-from-portable-simd-2025-01-18, ↵bors-6/+6
r=workingjubilee Portable SIMD subtree update r? `@workingjubilee`
2025-01-30std::rangePeter Jaszkowiak-16/+16
2025-01-27Reapply "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Michael Goulet-171/+151
r=davidtwco,RalfJung" This reverts commit 122a55bb442bd1995df9cf9b36e6f65ed3ef4a1d.
2025-01-20Rollup merge of #133695 - x17jiri:hint_likely, r=AmanieuMatthias Krüger-4/+4
Reexport likely/unlikely in std::hint Since `likely`/`unlikely` should be working now, we could reexport them in `std::hint`. I'm not sure if this is already approved or if it requires approval Tracking issue: #26179
2025-01-18Update tests for std::simd subtree syncCaleb Zulawski-6/+6
2025-01-18Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Rémy Rakic-151/+171
r=davidtwco,RalfJung" This reverts commit b57d93d8b9525fa261404b4cd9c0670eeb1264b8, reversing changes made to 0aeaa5eb22180fdf12a8489e63c4daa18da6f236.
2025-01-15Less unsafe in `dangling`/`without_provenance`Scott McMurray-38/+50