1
1
//@ compile-flags: -O -Z merge-functions=disabled
2
- //@ revisions: others riscv64
2
+ //@ revisions: others riscv64 loongarch64
3
3
4
4
//@[others] ignore-riscv64
5
+ //@[others] ignore-loongarch64
5
6
//@[riscv64] only-riscv64
6
7
//@[riscv64] compile-flags: --target riscv64gc-unknown-linux-gnu
7
8
//@[riscv64] needs-llvm-components: riscv
9
+ //@[loongarch64] only-loongarch64
10
+ //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu
11
+ //@[loongarch64] needs-llvm-components: loongarch
8
12
9
13
#![ crate_type = "lib" ]
10
14
#![ feature( unchecked_shifts) ]
14
18
// Thanks to poison semantics, this doesn't even need branches.
15
19
16
20
// CHECK-LABEL: @checked_sub_unsigned
17
- // others-SAME: (i16 noundef %a, i16 noundef %b)
18
- // riscv64-SAME: (i16 noundef zeroext %a, i16 noundef zeroext %b)
21
+ // others-SAME: (i16 noundef %a, i16 noundef %b)
22
+ // riscv64-SAME: (i16 noundef zeroext %a, i16 noundef zeroext %b)
23
+ // loongarch64-SAME: (i16 noundef zeroext %a, i16 noundef zeroext %b)
19
24
#[ no_mangle]
20
25
pub fn checked_sub_unsigned ( a : u16 , b : u16 ) -> Option < u16 > {
21
26
// CHECK-DAG: %[[IS_SOME:.+]] = icmp uge i16 %a, %b
@@ -33,8 +38,9 @@ pub fn checked_sub_unsigned(a: u16, b: u16) -> Option<u16> {
33
38
// looking for no-wrap flags, we just need there to not be any masking.
34
39
35
40
// CHECK-LABEL: @checked_shl_unsigned
36
- // others-SAME: (i32 noundef %a, i32 noundef %b)
37
- // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
41
+ // others-SAME: (i32 noundef %a, i32 noundef %b)
42
+ // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
43
+ // loongarch64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
38
44
#[ no_mangle]
39
45
pub fn checked_shl_unsigned ( a : u32 , b : u32 ) -> Option < u32 > {
40
46
// CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -49,8 +55,9 @@ pub fn checked_shl_unsigned(a: u32, b: u32) -> Option<u32> {
49
55
}
50
56
51
57
// CHECK-LABEL: @checked_shr_unsigned
52
- // others-SAME: (i32 noundef %a, i32 noundef %b)
53
- // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
58
+ // others-SAME: (i32 noundef %a, i32 noundef %b)
59
+ // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
60
+ // loongarch64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
54
61
#[ no_mangle]
55
62
pub fn checked_shr_unsigned ( a : u32 , b : u32 ) -> Option < u32 > {
56
63
// CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -65,8 +72,9 @@ pub fn checked_shr_unsigned(a: u32, b: u32) -> Option<u32> {
65
72
}
66
73
67
74
// CHECK-LABEL: @checked_shl_signed
68
- // others-SAME: (i32 noundef %a, i32 noundef %b)
69
- // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
75
+ // others-SAME: (i32 noundef %a, i32 noundef %b)
76
+ // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
77
+ // loongarch64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
70
78
#[ no_mangle]
71
79
pub fn checked_shl_signed ( a : i32 , b : u32 ) -> Option < i32 > {
72
80
// CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -81,8 +89,9 @@ pub fn checked_shl_signed(a: i32, b: u32) -> Option<i32> {
81
89
}
82
90
83
91
// CHECK-LABEL: @checked_shr_signed
84
- // others-SAME: (i32 noundef %a, i32 noundef %b)
85
- // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
92
+ // others-SAME: (i32 noundef %a, i32 noundef %b)
93
+ // riscv64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
94
+ // loongarch64-SAME: (i32 noundef signext %a, i32 noundef signext %b)
86
95
#[ no_mangle]
87
96
pub fn checked_shr_signed ( a : i32 , b : u32 ) -> Option < i32 > {
88
97
// CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -97,8 +106,9 @@ pub fn checked_shr_signed(a: i32, b: u32) -> Option<i32> {
97
106
}
98
107
99
108
// CHECK-LABEL: @checked_add_one_unwrap_unsigned
100
- // others-SAME: (i32 noundef %x)
101
- // riscv64-SAME: (i32 noundef signext %x)
109
+ // others-SAME: (i32 noundef %x)
110
+ // riscv64-SAME: (i32 noundef signext %x)
111
+ // loongarch64-SAME: (i32 noundef signext %x)
102
112
#[ no_mangle]
103
113
pub fn checked_add_one_unwrap_unsigned ( x : u32 ) -> u32 {
104
114
// CHECK: %[[IS_MAX:.+]] = icmp eq i32 %x, -1
0 commit comments