Fold arithmetic identities in GVN#119670
Conversation
|
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| let lhs = lhs?; | ||
| let rhs = rhs?; |
There was a problem hiding this comment.
you could do the ? op directly on the method calls above
There was a problem hiding this comment.
Added a comment explaining why it is done this way.
| let lhs = lhs?; | ||
| let rhs = rhs?; |
| // Represent the values as `Ok(bits)` or `Err(VnIndex)`. | ||
| let a = as_bits(lhs).ok_or(lhs); | ||
| let b = as_bits(rhs).ok_or(rhs); |
There was a problem hiding this comment.
Use Either instead of Result?
| (BinOp::Eq, a, b) if (a.is_ok() && b.is_ok()) || a == b => self.insert_bool(a == b), | ||
| (BinOp::Ne, a, b) if (a.is_ok() && b.is_ok()) || a == b => self.insert_bool(a != b), |
There was a problem hiding this comment.
why does it need to be ok for equality? wouldn't it also hold if they are the same VnIndex?
88f2fd8 to
61f3c06
Compare
|
☔ The latest upstream changes (presumably #119672) made this pull request unmergeable. Please resolve the merge conflicts. |
61f3c06 to
0623a95
Compare
|
@bors r+ |
0623a95 to
0cc2102
Compare
|
Blessed tests after rebasing. |
|
Perf effect is likely. |
Fold arithmetic identities in GVN Extracted from rust-lang#111344 This PR implements a few arithmetic folds for unary and binary operations. This should take care of the missed optimizations introduced by rust-lang#116012.
|
💔 Test failed - checks-actions |
|
Failure looks spurious. |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (52790a9): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 664.038s -> 665.924s (0.28%) |
|
Though this is a perf only fix, would T-compiler consider backporting? cc @mati865 |
Extracted from #111344
This PR implements a few arithmetic folds for unary and binary operations.
This should take care of the missed optimizations introduced by #116012.