-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #122387 - DianQK:re-enable-early-otherwise-branch, r=cj…
…gillot Re-enable the early otherwise branch optimization Closes #95162. Fixes #119014. This is the first part of #121397. An invalid enum discriminant can come from anywhere. We have to check to see if all successors contain the discriminant statement. This should have a pass to hoist instructions. r? cjgillot
- Loading branch information
Showing
16 changed files
with
615 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//@ compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub enum Enum { | ||
A(u32), | ||
B(u32), | ||
C(u32), | ||
} | ||
|
||
#[no_mangle] | ||
pub fn foo(lhs: &Enum, rhs: &Enum) -> bool { | ||
// CHECK-LABEL: define{{.*}}i1 @foo( | ||
// CHECK-NOT: switch | ||
// CHECK-NOT: br | ||
// CHECK: [[SELECT:%.*]] = select | ||
// CHECK-NEXT: ret i1 [[SELECT]] | ||
// CHECK-NEXT: } | ||
match (lhs, rhs) { | ||
(Enum::A(lhs), Enum::A(rhs)) => lhs == rhs, | ||
(Enum::B(lhs), Enum::B(rhs)) => lhs == rhs, | ||
(Enum::C(lhs), Enum::C(rhs)) => lhs == rhs, | ||
_ => false, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.