Skip to content

Commit c4b8c57

Browse files
committed
Use -Cdebug-assertions instead of -Coverlow-checks in tests
1 parent cb2b3ea commit c4b8c57

15 files changed

+58
-22
lines changed

compiler/rustc_mir_transform/src/simplify_pow_of_two.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
222222
loc,
223223
overflowed.into(),
224224
Rvalue::BinaryOp(
225-
BinOp::BitAnd,
225+
BinOp::BitOr,
226226
Box::new((
227227
Operand::Copy(shl_eq_shr.into()),
228228
Operand::Copy(shl_result.into()),
@@ -234,7 +234,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
234234
i,
235235
TerminatorKind::Assert {
236236
cond: Operand::Copy(overflowed.into()),
237-
expected: true,
237+
expected: false,
238238
msg: Box::new(AssertMessage::Overflow(
239239
// For consistency with the previous error message, though
240240
// it's technically incorrect

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Coverflow-checks=false
1+
// compile-flags: -Cdebug-assertions=false
22

33
// EMIT_MIR simplify_pow_of_two_no_overflow_checks.slow_2_u.SimplifyPowOfTwo.diff
44
fn slow_2_u(a: u32) -> u32 {

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.slow_256_i.SimplifyPowOfTwo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bb0: {
1616
StorageLive(_2);
1717
_2 = _1;
18-
- _0 = core::num::<impl i32>::pow(const 256_i32, move _2) -> [return: bb1, unwind unreachable];
18+
- _0 = core::num::<impl i32>::pow(const 256_i32, move _2) -> [return: bb1, unwind continue];
1919
+ _3 = CheckedMul(move _2, const 8_u32);
2020
+ _4 = Lt((_3.0: u32), const 32_u32);
2121
+ _5 = BitOr((_3.1: bool), _4);

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.slow_256_u.SimplifyPowOfTwo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bb0: {
1616
StorageLive(_2);
1717
_2 = _1;
18-
- _0 = core::num::<impl u32>::pow(const 256_u32, move _2) -> [return: bb1, unwind unreachable];
18+
- _0 = core::num::<impl u32>::pow(const 256_u32, move _2) -> [return: bb1, unwind continue];
1919
+ _3 = CheckedMul(move _2, const 8_u32);
2020
+ _4 = Lt((_3.0: u32), const 32_u32);
2121
+ _5 = BitOr((_3.1: bool), _4);

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.slow_2_i.SimplifyPowOfTwo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bb0: {
1616
StorageLive(_2);
1717
_2 = _1;
18-
- _0 = core::num::<impl i32>::pow(const 2_i32, move _2) -> [return: bb1, unwind unreachable];
18+
- _0 = core::num::<impl i32>::pow(const 2_i32, move _2) -> [return: bb1, unwind continue];
1919
+ _3 = CheckedMul(move _2, const 1_u32);
2020
+ _4 = Lt((_3.0: u32), const 32_u32);
2121
+ _5 = BitOr((_3.1: bool), _4);

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.slow_2_u.SimplifyPowOfTwo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bb0: {
1616
StorageLive(_2);
1717
_2 = _1;
18-
- _0 = core::num::<impl u32>::pow(const 2_u32, move _2) -> [return: bb1, unwind unreachable];
18+
- _0 = core::num::<impl u32>::pow(const 2_u32, move _2) -> [return: bb1, unwind continue];
1919
+ _3 = CheckedMul(move _2, const 1_u32);
2020
+ _4 = Lt((_3.0: u32), const 32_u32);
2121
+ _5 = BitOr((_3.1: bool), _4);

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.slow_4_i.SimplifyPowOfTwo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bb0: {
1616
StorageLive(_2);
1717
_2 = _1;
18-
- _0 = core::num::<impl i32>::pow(const 4_i32, move _2) -> [return: bb1, unwind unreachable];
18+
- _0 = core::num::<impl i32>::pow(const 4_i32, move _2) -> [return: bb1, unwind continue];
1919
+ _3 = CheckedMul(move _2, const 2_u32);
2020
+ _4 = Lt((_3.0: u32), const 32_u32);
2121
+ _5 = BitOr((_3.1: bool), _4);

tests/mir-opt/simplify_pow_of_two_no_overflow_checks.slow_4_u.SimplifyPowOfTwo.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
bb0: {
1616
StorageLive(_2);
1717
_2 = _1;
18-
- _0 = core::num::<impl u32>::pow(const 4_u32, move _2) -> [return: bb1, unwind unreachable];
18+
- _0 = core::num::<impl u32>::pow(const 4_u32, move _2) -> [return: bb1, unwind continue];
1919
+ _3 = CheckedMul(move _2, const 2_u32);
2020
+ _4 = Lt((_3.0: u32), const 32_u32);
2121
+ _5 = BitOr((_3.1: bool), _4);

tests/mir-opt/simplify_pow_of_two_overflow_checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Coverflow-checks=true
1+
// compile-flags: -Cdebug-assertions=true
22

33
// EMIT_MIR simplify_pow_of_two_overflow_checks.slow_2_u.SimplifyPowOfTwo.diff
44
fn slow_2_u(a: u32) -> u32 {

tests/mir-opt/simplify_pow_of_two_overflow_checks.slow_256_i.SimplifyPowOfTwo.diff

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
+ let mut _6: i32;
1212
+ let mut _7: u32;
1313
+ let mut _8: i32;
14+
+ let mut _9: i32;
15+
+ let mut _10: bool;
16+
+ let mut _11: bool;
1417

1518
bb0: {
1619
StorageLive(_2);
1720
_2 = _1;
18-
- _0 = core::num::<impl i32>::pow(const 256_i32, move _2) -> [return: bb1, unwind unreachable];
21+
- _0 = core::num::<impl i32>::pow(const 256_i32, move _2) -> [return: bb1, unwind continue];
1922
+ _3 = CheckedMul(move _2, const 8_u32);
2023
+ _4 = Lt((_3.0: u32), const 32_u32);
2124
+ _5 = BitOr((_3.1: bool), _4);
2225
+ _6 = _5 as i32 (IntToInt);
2326
+ _7 = Shl(const 1_u32, (_3.0: u32));
2427
+ _8 = _7 as i32 (IntToInt);
2528
+ _0 = MulUnchecked(_8, _6);
26-
+ goto -> bb1;
29+
+ _9 = Shr(_8, (_3.0: u32));
30+
+ _10 = Eq(_8, _9);
31+
+ _11 = BitOr(_10, _4);
32+
+ assert(!_11, "attempt to compute `{} * {}`, which would overflow", const 1_u32, (_3.0: u32)) -> [success: bb1, unwind continue];
2733
}
2834

2935
bb1: {

tests/mir-opt/simplify_pow_of_two_overflow_checks.slow_256_u.SimplifyPowOfTwo.diff

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
+ let mut _6: u32;
1212
+ let mut _7: u32;
1313
+ let mut _8: u32;
14+
+ let mut _9: u32;
15+
+ let mut _10: bool;
16+
+ let mut _11: bool;
1417

1518
bb0: {
1619
StorageLive(_2);
1720
_2 = _1;
18-
- _0 = core::num::<impl u32>::pow(const 256_u32, move _2) -> [return: bb1, unwind unreachable];
21+
- _0 = core::num::<impl u32>::pow(const 256_u32, move _2) -> [return: bb1, unwind continue];
1922
+ _3 = CheckedMul(move _2, const 8_u32);
2023
+ _4 = Lt((_3.0: u32), const 32_u32);
2124
+ _5 = BitOr((_3.1: bool), _4);
2225
+ _6 = _5 as u32 (IntToInt);
2326
+ _7 = Shl(const 1_u32, (_3.0: u32));
2427
+ _8 = _7 as u32 (IntToInt);
2528
+ _0 = MulUnchecked(_8, _6);
26-
+ goto -> bb1;
29+
+ _9 = Shr(_8, (_3.0: u32));
30+
+ _10 = Eq(_8, _9);
31+
+ _11 = BitOr(_10, _4);
32+
+ assert(!_11, "attempt to compute `{} * {}`, which would overflow", const 1_u32, (_3.0: u32)) -> [success: bb1, unwind continue];
2733
}
2834

2935
bb1: {

tests/mir-opt/simplify_pow_of_two_overflow_checks.slow_2_i.SimplifyPowOfTwo.diff

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
+ let mut _6: i32;
1212
+ let mut _7: u32;
1313
+ let mut _8: i32;
14+
+ let mut _9: i32;
15+
+ let mut _10: bool;
16+
+ let mut _11: bool;
1417

1518
bb0: {
1619
StorageLive(_2);
1720
_2 = _1;
18-
- _0 = core::num::<impl i32>::pow(const 2_i32, move _2) -> [return: bb1, unwind unreachable];
21+
- _0 = core::num::<impl i32>::pow(const 2_i32, move _2) -> [return: bb1, unwind continue];
1922
+ _3 = CheckedMul(move _2, const 1_u32);
2023
+ _4 = Lt((_3.0: u32), const 32_u32);
2124
+ _5 = BitOr((_3.1: bool), _4);
2225
+ _6 = _5 as i32 (IntToInt);
2326
+ _7 = Shl(const 1_u32, (_3.0: u32));
2427
+ _8 = _7 as i32 (IntToInt);
2528
+ _0 = MulUnchecked(_8, _6);
26-
+ goto -> bb1;
29+
+ _9 = Shr(_8, (_3.0: u32));
30+
+ _10 = Eq(_8, _9);
31+
+ _11 = BitOr(_10, _4);
32+
+ assert(!_11, "attempt to compute `{} * {}`, which would overflow", const 1_u32, (_3.0: u32)) -> [success: bb1, unwind continue];
2733
}
2834

2935
bb1: {

tests/mir-opt/simplify_pow_of_two_overflow_checks.slow_2_u.SimplifyPowOfTwo.diff

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
+ let mut _6: u32;
1212
+ let mut _7: u32;
1313
+ let mut _8: u32;
14+
+ let mut _9: u32;
15+
+ let mut _10: bool;
16+
+ let mut _11: bool;
1417

1518
bb0: {
1619
StorageLive(_2);
1720
_2 = _1;
18-
- _0 = core::num::<impl u32>::pow(const 2_u32, move _2) -> [return: bb1, unwind unreachable];
21+
- _0 = core::num::<impl u32>::pow(const 2_u32, move _2) -> [return: bb1, unwind continue];
1922
+ _3 = CheckedMul(move _2, const 1_u32);
2023
+ _4 = Lt((_3.0: u32), const 32_u32);
2124
+ _5 = BitOr((_3.1: bool), _4);
2225
+ _6 = _5 as u32 (IntToInt);
2326
+ _7 = Shl(const 1_u32, (_3.0: u32));
2427
+ _8 = _7 as u32 (IntToInt);
2528
+ _0 = MulUnchecked(_8, _6);
26-
+ goto -> bb1;
29+
+ _9 = Shr(_8, (_3.0: u32));
30+
+ _10 = Eq(_8, _9);
31+
+ _11 = BitOr(_10, _4);
32+
+ assert(!_11, "attempt to compute `{} * {}`, which would overflow", const 1_u32, (_3.0: u32)) -> [success: bb1, unwind continue];
2733
}
2834

2935
bb1: {

tests/mir-opt/simplify_pow_of_two_overflow_checks.slow_4_i.SimplifyPowOfTwo.diff

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
+ let mut _6: i32;
1212
+ let mut _7: u32;
1313
+ let mut _8: i32;
14+
+ let mut _9: i32;
15+
+ let mut _10: bool;
16+
+ let mut _11: bool;
1417

1518
bb0: {
1619
StorageLive(_2);
1720
_2 = _1;
18-
- _0 = core::num::<impl i32>::pow(const 4_i32, move _2) -> [return: bb1, unwind unreachable];
21+
- _0 = core::num::<impl i32>::pow(const 4_i32, move _2) -> [return: bb1, unwind continue];
1922
+ _3 = CheckedMul(move _2, const 2_u32);
2023
+ _4 = Lt((_3.0: u32), const 32_u32);
2124
+ _5 = BitOr((_3.1: bool), _4);
2225
+ _6 = _5 as i32 (IntToInt);
2326
+ _7 = Shl(const 1_u32, (_3.0: u32));
2427
+ _8 = _7 as i32 (IntToInt);
2528
+ _0 = MulUnchecked(_8, _6);
26-
+ goto -> bb1;
29+
+ _9 = Shr(_8, (_3.0: u32));
30+
+ _10 = Eq(_8, _9);
31+
+ _11 = BitOr(_10, _4);
32+
+ assert(!_11, "attempt to compute `{} * {}`, which would overflow", const 1_u32, (_3.0: u32)) -> [success: bb1, unwind continue];
2733
}
2834

2935
bb1: {

tests/mir-opt/simplify_pow_of_two_overflow_checks.slow_4_u.SimplifyPowOfTwo.diff

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@
1111
+ let mut _6: u32;
1212
+ let mut _7: u32;
1313
+ let mut _8: u32;
14+
+ let mut _9: u32;
15+
+ let mut _10: bool;
16+
+ let mut _11: bool;
1417

1518
bb0: {
1619
StorageLive(_2);
1720
_2 = _1;
18-
- _0 = core::num::<impl u32>::pow(const 4_u32, move _2) -> [return: bb1, unwind unreachable];
21+
- _0 = core::num::<impl u32>::pow(const 4_u32, move _2) -> [return: bb1, unwind continue];
1922
+ _3 = CheckedMul(move _2, const 2_u32);
2023
+ _4 = Lt((_3.0: u32), const 32_u32);
2124
+ _5 = BitOr((_3.1: bool), _4);
2225
+ _6 = _5 as u32 (IntToInt);
2326
+ _7 = Shl(const 1_u32, (_3.0: u32));
2427
+ _8 = _7 as u32 (IntToInt);
2528
+ _0 = MulUnchecked(_8, _6);
26-
+ goto -> bb1;
29+
+ _9 = Shr(_8, (_3.0: u32));
30+
+ _10 = Eq(_8, _9);
31+
+ _11 = BitOr(_10, _4);
32+
+ assert(!_11, "attempt to compute `{} * {}`, which would overflow", const 1_u32, (_3.0: u32)) -> [success: bb1, unwind continue];
2733
}
2834

2935
bb1: {

0 commit comments

Comments
 (0)