Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-eabihf",
"only-elf",
"only-emscripten",
"only-endian-big",
"only-gnu",
"only-i686-pc-windows-gnu",
"only-i686-pc-windows-msvc",
Expand Down
51 changes: 43 additions & 8 deletions tests/codegen-llvm/issues/multiple-option-or-permutations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Tests output of multiple permutations of `Option::or`
//@ revisions: LITTLE BIG
//@ [BIG] only-endian-big
//@ [LITTLE] ignore-endian-big
//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled

#![crate_type = "lib"]
Expand Down Expand Up @@ -70,8 +73,16 @@ pub fn if_some_u8(opta: Option<u8>, optb: Option<u8>) -> Option<u8> {
#[no_mangle]
pub fn or_match_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
// CHECK: start:
// CHECK-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// CHECK-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// LITTLE-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// LITTLE-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[OPT_A:%.+]] = lshr i16 %0, 8
// BIG-NEXT: [[SOME_A:%.+]] = trunc i16 [[OPT_A]] to i1
// BIG-NEXT: [[OPT_B:%.+]] = lshr i16 %1, 8
// BIG-NEXT: [[A_OR_B:%.+]] = select i1 [[SOME_A]], i16 [[OPT_A]], i16 [[OPT_B]]
// BIG-NEXT: [[AGGREGATE:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[R_LOWER:%.+]] = and i16 [[AGGREGATE]], 255
// BIG-NEXT: [[R_UPPER:%.+]] = shl nuw i16 [[A_OR_B]], 8
// BIG-NEXT: [[R:%.+]] = or disjoint i16 [[R_UPPER]], [[R_LOWER]]
// CHECK: ret i16 [[R]]
match opta {
Some(x) => Some(x),
Expand All @@ -84,8 +95,16 @@ pub fn or_match_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option
#[no_mangle]
pub fn or_match_slice_alt_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
// CHECK: start:
// CHECK-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// CHECK-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// LITTLE-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// LITTLE-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[OPT_A:%.+]] = lshr i16 %0, 8
// BIG-NEXT: [[SOME_A:%.+]] = trunc i16 [[OPT_A]] to i1
// BIG-NEXT: [[OPT_B:%.+]] = lshr i16 %1, 8
// BIG-NEXT: [[A_OR_B:%.+]] = select i1 [[SOME_A]], i16 [[OPT_A]], i16 [[OPT_B]]
// BIG-NEXT: [[AGGREGATE:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[R_LOWER:%.+]] = and i16 [[AGGREGATE]], 255
// BIG-NEXT: [[R_UPPER:%.+]] = shl nuw i16 [[A_OR_B]], 8
// BIG-NEXT: [[R:%.+]] = or disjoint i16 [[R_UPPER]], [[R_LOWER]]
// CHECK: ret i16 [[R]]
match opta {
Some(_) => opta,
Expand All @@ -98,8 +117,16 @@ pub fn or_match_slice_alt_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Op
#[no_mangle]
pub fn option_or_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
// CHECK: start:
// CHECK-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// CHECK-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// LITTLE-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// LITTLE-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[OPT_A:%.+]] = lshr i16 %0, 8
// BIG-NEXT: [[SOME_A:%.+]] = trunc i16 [[OPT_A]] to i1
// BIG-NEXT: [[OPT_B:%.+]] = lshr i16 %1, 8
// BIG-NEXT: [[A_OR_B:%.+]] = select i1 [[SOME_A]], i16 [[OPT_A]], i16 [[OPT_B]]
// BIG-NEXT: [[AGGREGATE:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[R_LOWER:%.+]] = and i16 [[AGGREGATE]], 255
// BIG-NEXT: [[R_UPPER:%.+]] = shl nuw i16 [[A_OR_B]], 8
// BIG-NEXT: [[R:%.+]] = or disjoint i16 [[R_UPPER]], [[R_LOWER]]
// CHECK: ret i16 [[R]]
opta.or(optb)
}
Expand All @@ -109,8 +136,16 @@ pub fn option_or_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Optio
#[no_mangle]
pub fn if_some_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
// CHECK: start:
// CHECK-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// CHECK-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// LITTLE-NEXT: [[SOME_A:%.+]] = trunc i16 %0 to i1
// LITTLE-NEXT: [[R:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[OPT_A:%.+]] = lshr i16 %0, 8
// BIG-NEXT: [[SOME_A:%.+]] = trunc i16 [[OPT_A]] to i1
// BIG-NEXT: [[OPT_B:%.+]] = lshr i16 %1, 8
// BIG-NEXT: [[A_OR_B:%.+]] = select i1 [[SOME_A]], i16 [[OPT_A]], i16 [[OPT_B]]
// BIG-NEXT: [[AGGREGATE:%.+]] = select i1 [[SOME_A]], i16 %0, i16 %1
// BIG-NEXT: [[R_LOWER:%.+]] = and i16 [[AGGREGATE]], 255
// BIG-NEXT: [[R_UPPER:%.+]] = shl nuw i16 [[A_OR_B]], 8
// BIG-NEXT: [[R:%.+]] = or disjoint i16 [[R_UPPER]], [[R_LOWER]]
// CHECK: ret i16 [[R]]
if opta.is_some() { opta } else { optb }
}
Expand Down
Loading