mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
fix: refactored to use directives instead of CHECK-DAG
This commit is contained in:
@@ -218,6 +218,7 @@
|
||||
"only-eabihf",
|
||||
"only-elf",
|
||||
"only-emscripten",
|
||||
"only-endian-big",
|
||||
"only-gnu",
|
||||
"only-i686-pc-windows-gnu",
|
||||
"only-i686-pc-windows-msvc",
|
||||
|
||||
@@ -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"]
|
||||
@@ -70,9 +73,17 @@ 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-DAG: [[SOME_A:%.+]] = trunc i16 {{.*}} to i1
|
||||
// CHECK-DAG: select i1 [[SOME_A]], i16 %0, i16 %1
|
||||
// CHECK: ret i16 {{.*}}
|
||||
// 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),
|
||||
None => optb,
|
||||
@@ -84,9 +95,17 @@ pub fn if_some_u8(opta: Option<u8>, optb: Option<u8>) -> Option<u8> {
|
||||
#[no_mangle]
|
||||
pub fn or_match_slice_alt_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
|
||||
// CHECK: start:
|
||||
// CHECK-DAG: [[SOME_A:%.+]] = trunc i16 {{.*}} to i1
|
||||
// CHECK-DAG: select i1 [[SOME_A]], i16 %0, i16 %1
|
||||
// CHECK: ret i16 {{.*}}
|
||||
// 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,
|
||||
None => optb,
|
||||
@@ -98,9 +117,17 @@ pub fn if_some_u8(opta: Option<u8>, optb: Option<u8>) -> Option<u8> {
|
||||
#[no_mangle]
|
||||
pub fn option_or_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
|
||||
// CHECK: start:
|
||||
// CHECK-DAG: [[SOME_A:%.+]] = trunc i16 {{.*}} to i1
|
||||
// CHECK-DAG: select i1 [[SOME_A]], i16 %0, i16 %1
|
||||
// CHECK: ret i16 {{.*}}
|
||||
// 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)
|
||||
}
|
||||
|
||||
@@ -109,9 +136,17 @@ pub fn if_some_u8(opta: Option<u8>, optb: Option<u8>) -> Option<u8> {
|
||||
#[no_mangle]
|
||||
pub fn if_some_slice_u8(opta: Option<[u8; 1]>, optb: Option<[u8; 1]>) -> Option<[u8; 1]> {
|
||||
// CHECK: start:
|
||||
// CHECK-DAG: [[SOME_A:%.+]] = trunc i16 {{.*}} to i1
|
||||
// CHECK-DAG: select i1 [[SOME_A]], i16 %0, i16 %1
|
||||
// CHECK: ret i16 {{.*}}
|
||||
// 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 }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user