rust/tests/mir-opt/building
Matthias Krüger 7afed92749
Rollup merge of #109475 - scottmcm:simpler-shifts, r=WaffleLapkin
Simpler checked shifts in MIR building

Doing masking to check unsigned shift amounts is overcomplicated; just comparing the shift directly saves a statement and a temporary, as well as is much easier to read as a human.  And shifting by unsigned is the canonical case -- notably, all the library shifting methods (that don't support every type) take shift RHSs as `u32` -- so we might as well make that simpler since it's easy to do so.

This PR also changes *signed* shift amounts to `IntToInt` casts and then uses the same check as for unsigned.  The bit-masking is a nice trick, but for example LLVM actually canonicalizes it to an unsigned comparison anyway <https://rust.godbolt.org/z/8h59fMGT4> so I don't think it's worth the effort and the extra `Constant`.  (If MIR's `assert` was `assert_nz` then the masking might make sense, but when the `!=` uses another statement I think the comparison is better.)

To review, I suggest looking at 2ee0468c49 first -- that's the interesting code change and has a MIR diff.

My favourite part of the diff:
```diff
-        _20 = BitAnd(_19, const 340282366920938463463374607431768211448_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44
-        _21 = Ne(move _20, const 0_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44
-        assert(!move _21, "attempt to shift right by `{}`, which would overflow", _19) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44
+        _18 = Lt(_17, const 8_u128);     // scope 0 at $DIR/shifts.rs:+2:34: +2:44
+        assert(move _18, "attempt to shift right by `{}`, which would overflow", _17) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44
```
2023-03-23 08:35:35 +01:00
..
custom Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegen 2023-03-22 20:08:01 +01:00
async_await.a-{closure#0}.generator_resume.0.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
async_await.b-{closure#0}.generator_resume.0.mir Remove identity_future indirection 2023-03-08 15:37:14 +01:00
async_await.rs Transform async ResumeTy in generator transform 2023-01-19 09:03:05 +01:00
enum_cast.bar.built.after.mir
enum_cast.boo.built.after.mir
enum_cast.droppy.built.after.mir
enum_cast.foo.built.after.mir
enum_cast.rs
issue_49232.main.built.after.mir
issue_49232.rs
issue_101867.main.built.after.mir
issue_101867.rs
match_false_edges.full_tested_match2.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
match_false_edges.full_tested_match.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
match_false_edges.main.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
match_false_edges.rs
receiver_ptr_mutability.main.built.after.mir
receiver_ptr_mutability.rs
shifts.rs Demonstration test for MIR building of checked shift operators 2023-03-22 01:37:11 -07:00
shifts.shift_signed.built.after.mir Generate simpler MIR for shifts 2023-03-22 13:32:12 -07:00
shifts.shift_unsigned.built.after.mir Generate simpler MIR for shifts 2023-03-22 13:32:12 -07:00
simple_match.match_bool.built.after.mir
simple_match.rs
storage_live_dead_in_statics.rs
storage_live_dead_in_statics.XXX.built.after.mir
uniform_array_move_out.move_out_by_subslice.built.after.mir Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
uniform_array_move_out.move_out_from_end.built.after.mir Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
uniform_array_move_out.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00