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-12 00:13:15 +00:00
|
|
|
- // MIR for `id_try` before SimplifyBranchSame
|
|
|
|
+ // MIR for `id_try` after SimplifyBranchSame
|
2020-09-07 09:01:45 +00:00
|
|
|
|
2021-01-28 16:01:36 +00:00
|
|
|
fn id_try(_1: Result<u8, i32>) -> Result<u8, i32> {
|
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-12 00:13:15 +00:00
|
|
|
debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:23:11: 23:12
|
|
|
|
let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify-arm.rs:23:34: 23:49
|
|
|
|
let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:24:9: 24:10
|
|
|
|
let mut _3: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:24:13: 24:15
|
|
|
|
let mut _4: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:24:13: 24:14
|
|
|
|
let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:24:13: 24:15
|
|
|
|
let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:25:8: 25:9
|
|
|
|
scope 1 {
|
2020-07-25 15:46:11 +00:00
|
|
|
debug x => ((_0 as Ok).0: u8); // in scope 1 at $DIR/simplify-arm.rs:24:9: 24: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-12 00:13:15 +00:00
|
|
|
}
|
|
|
|
scope 2 {
|
2020-07-25 15:46:11 +00:00
|
|
|
debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify-arm.rs:24:14: 24:15
|
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-12 00:13:15 +00:00
|
|
|
scope 3 {
|
2020-02-08 19:31:09 +00:00
|
|
|
scope 7 (inlined <i32 as From<i32>>::from) { // at $DIR/simplify-arm.rs:24:14: 24:15
|
2020-09-19 16:56:32 +00:00
|
|
|
debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15
|
2020-07-25 15:46:11 +00:00
|
|
|
}
|
2021-01-28 16:01:36 +00:00
|
|
|
scope 8 (inlined <Result<u8, i32> as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15
|
2020-09-19 16:56:32 +00:00
|
|
|
debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15
|
|
|
|
let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15
|
2020-07-25 15:46:11 +00: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-12 00:13:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
scope 4 {
|
2020-07-25 15:46:11 +00:00
|
|
|
debug val => ((_0 as Ok).0: u8); // in scope 4 at $DIR/simplify-arm.rs:24:13: 24:15
|
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-12 00:13:15 +00:00
|
|
|
scope 5 {
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 16:01:36 +00:00
|
|
|
scope 6 (inlined <Result<u8, i32> as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15
|
2020-09-19 16:56:32 +00:00
|
|
|
debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15
|
2020-07-25 15:46:11 +00:00
|
|
|
}
|
2020-09-07 09:01:45 +00: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-12 00:13:15 +00:00
|
|
|
bb0: {
|
|
|
|
StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:24:9: 24:10
|
|
|
|
StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15
|
|
|
|
StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14
|
|
|
|
_4 = _1; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:14
|
2020-09-19 16:56:32 +00:00
|
|
|
_3 = move _4; // scope 6 at $DIR/simplify-arm.rs:24:13: 24:15
|
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-12 00:13:15 +00:00
|
|
|
StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
_5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
2020-07-25 15:46:11 +00:00
|
|
|
- switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
|
|
|
+ goto -> bb1; // scope 0 at $DIR/simplify-arm.rs:24:14: 24:15
|
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-12 00:13:15 +00:00
|
|
|
}
|
2020-09-07 09:01:45 +00:00
|
|
|
|
2020-07-25 15:46:11 +00:00
|
|
|
bb1: {
|
|
|
|
_0 = move _3; // scope 1 at $DIR/simplify-arm.rs:25:5: 25: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-12 00:13:15 +00:00
|
|
|
StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16
|
|
|
|
StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2
|
2020-07-25 15:46:11 +00:00
|
|
|
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
|
|
|
|
+ goto -> bb2; // scope 0 at $DIR/simplify-arm.rs:26:2: 26: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-12 00:13:15 +00:00
|
|
|
}
|
2020-09-07 09:01:45 +00:00
|
|
|
|
2020-07-25 15:46:11 +00:00
|
|
|
bb2: {
|
|
|
|
- unreachable; // scope 0 at $DIR/simplify-arm.rs:24:13: 24:15
|
|
|
|
- }
|
2020-09-07 09:01:45 +00:00
|
|
|
-
|
2020-07-25 15:46:11 +00:00
|
|
|
- bb3: {
|
2020-09-19 16:56:32 +00:00
|
|
|
- _0 = move _3; // scope 8 at $DIR/simplify-arm.rs:24:13: 24:15
|
2020-07-25 15:46:11 +00:00
|
|
|
- StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:24:15: 24:16
|
|
|
|
- StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:26:1: 26:2
|
2020-10-02 20:11:24 +00:00
|
|
|
- goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:26:2: 26:2
|
2020-07-25 15:46:11 +00:00
|
|
|
- }
|
2020-09-07 09:01:45 +00:00
|
|
|
-
|
2020-07-25 15:46:11 +00:00
|
|
|
- bb4: {
|
2020-06-04 16:26:13 +00:00
|
|
|
return; // scope 0 at $DIR/simplify-arm.rs:26:2: 26: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-12 00:13:15 +00:00
|
|
|
}
|
2020-09-07 09:01:45 +00:00
|
|
|
|