Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
- // MIR for `id_try` before SimplifyArmIdentity
|
|
|
|
+ // MIR for `id_try` after SimplifyArmIdentity
|
2020-09-07 10:01:45 +01:00
|
|
|
|
2021-01-28 18:01:36 +02:00
|
|
|
fn id_try(_1: Result<u8, i32>) -> Result<u8, i32> {
|
2021-04-25 22:02:48 -07:00
|
|
|
debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:35:11: 35:12
|
|
|
|
let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify-arm.rs:35:34: 35:49
|
|
|
|
let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:36:9: 36:10
|
|
|
|
let mut _3: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:36:19: 36:33
|
|
|
|
let mut _4: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:36:31: 36:32
|
|
|
|
let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:37:9: 37:15
|
|
|
|
let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:37:13: 37:14
|
|
|
|
let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:37:19: 37:51
|
|
|
|
let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:37:37: 37:50
|
|
|
|
let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:37:48: 37:49
|
|
|
|
let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:38:12: 38:13
|
|
|
|
let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:40:8: 40:9
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
scope 1 {
|
2021-04-25 22:02:48 -07:00
|
|
|
- debug x => _2; // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10
|
|
|
|
+ debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:36:9: 36:10
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
|
|
|
scope 2 {
|
2021-04-25 22:02:48 -07:00
|
|
|
- debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14
|
|
|
|
+ debug e => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:37:13: 37:14
|
|
|
|
scope 5 (inlined <i32 as From<i32>>::from) { // at $DIR/simplify-arm.rs:37:37: 37:50
|
2022-02-27 16:09:52 +01:00
|
|
|
- debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
|
|
|
+ debug t => ((_0 as Err).0: i32); // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
2021-04-25 22:02:48 -07:00
|
|
|
scope 6 (inlined from_error::<u8, i32>) { // at $DIR/simplify-arm.rs:37:26: 37:51
|
2022-02-27 16:09:52 +01:00
|
|
|
- debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:27:21: 27:22
|
|
|
|
+ debug e => ((_0 as Err).0: i32); // in scope 6 at $DIR/simplify-arm.rs:27:21: 27:22
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
|
|
|
}
|
2021-04-25 22:02:48 -07:00
|
|
|
scope 3 {
|
|
|
|
- debug v => _10; // in scope 3 at $DIR/simplify-arm.rs:38:12: 38:13
|
|
|
|
+ debug v => ((_0 as Ok).0: u8); // in scope 3 at $DIR/simplify-arm.rs:38:12: 38:13
|
|
|
|
}
|
|
|
|
scope 4 (inlined into_result::<u8, i32>) { // at $DIR/simplify-arm.rs:36:19: 36:33
|
2022-02-27 16:09:52 +01:00
|
|
|
debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:23:22: 23:23
|
2020-07-25 17:46:11 +02:00
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
bb0: {
|
2021-04-25 22:02:48 -07:00
|
|
|
StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:36:9: 36:10
|
|
|
|
StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33
|
|
|
|
StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:36:31: 36:32
|
|
|
|
_4 = _1; // scope 0 at $DIR/simplify-arm.rs:36:31: 36:32
|
2022-02-27 16:09:52 +01:00
|
|
|
_3 = move _4; // scope 4 at $DIR/simplify-arm.rs:24:5: 24:6
|
2021-04-25 22:02:48 -07:00
|
|
|
StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:36:32: 36:33
|
2021-07-23 18:55:36 -04:00
|
|
|
_5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33
|
|
|
|
switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:36:13: 36:33
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
|
2020-07-25 17:46:11 +02:00
|
|
|
bb1: {
|
2021-04-25 22:02:48 -07:00
|
|
|
- StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:38:12: 38:13
|
|
|
|
- _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:38:12: 38:13
|
|
|
|
- _2 = _10; // scope 3 at $DIR/simplify-arm.rs:38:18: 38:19
|
|
|
|
- StorageDead(_10); // scope 0 at $DIR/simplify-arm.rs:38:18: 38:19
|
|
|
|
+ _0 = move _3; // scope 1 at $DIR/simplify-arm.rs:40:5: 40:10
|
|
|
|
StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:39:6: 39:7
|
|
|
|
- StorageLive(_11); // scope 1 at $DIR/simplify-arm.rs:40:8: 40:9
|
|
|
|
- _11 = _2; // scope 1 at $DIR/simplify-arm.rs:40:8: 40:9
|
|
|
|
- ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify-arm.rs:40:5: 40:10
|
|
|
|
- discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:40:5: 40:10
|
|
|
|
- StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:40:9: 40:10
|
|
|
|
StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:41:1: 41:2
|
|
|
|
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
|
2020-07-25 17:46:11 +02:00
|
|
|
bb2: {
|
2021-04-25 22:02:48 -07:00
|
|
|
unreachable; // scope 0 at $DIR/simplify-arm.rs:36:19: 36:33
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
|
2020-07-25 17:46:11 +02:00
|
|
|
bb3: {
|
2021-04-25 22:02:48 -07:00
|
|
|
- StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14
|
|
|
|
- _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:37:13: 37:14
|
|
|
|
- StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:37:37: 37:50
|
|
|
|
- StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49
|
|
|
|
- _9 = _6; // scope 2 at $DIR/simplify-arm.rs:37:48: 37:49
|
2022-02-27 16:09:52 +01:00
|
|
|
- _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
2021-04-25 22:02:48 -07:00
|
|
|
- StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:37:49: 37:50
|
2022-02-27 16:09:52 +01:00
|
|
|
- ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify-arm.rs:28:9: 28:10
|
|
|
|
- discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11
|
2021-04-25 22:02:48 -07:00
|
|
|
- StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:37:50: 37:51
|
|
|
|
- StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:37:50: 37:51
|
2022-02-27 16:09:52 +01:00
|
|
|
+ _0 = move _3; // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11
|
2021-04-25 22:02:48 -07:00
|
|
|
StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:39:6: 39:7
|
|
|
|
StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:41:1: 41:2
|
|
|
|
goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
|
2020-07-25 17:46:11 +02:00
|
|
|
bb4: {
|
2021-04-25 22:02:48 -07:00
|
|
|
return; // scope 0 at $DIR/simplify-arm.rs:41:2: 41:2
|
2020-06-04 12:26:13 -04:00
|
|
|
}
|
Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
2020-05-11 20:13:15 -04:00
|
|
|
}
|
2020-09-07 10:01:45 +01:00
|
|
|
|