11//@ compile-flags: -O -Z merge-functions=disabled
2- //@ revisions: others riscv64
2+ //@ revisions: others riscv64 loongarch64
33
44//@[others] ignore-riscv64
5+ //@[others] ignore-loongarch64
56//@[riscv64] only-riscv64
67//@[riscv64] compile-flags: --target riscv64gc-unknown-linux-gnu
78//@[riscv64] needs-llvm-components: riscv
9+ //@[loongarch64] only-loongarch64
10+ //@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu
11+ //@[loongarch64] needs-llvm-components: loongarch
812
913#![ crate_type = "lib" ]
1014#![ feature( unchecked_shifts) ]
1418// Thanks to poison semantics, this doesn't even need branches.
1519
1620// 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)
1924#[ no_mangle]
2025pub fn checked_sub_unsigned ( a : u16 , b : u16 ) -> Option < u16 > {
2126 // CHECK-DAG: %[[IS_SOME:.+]] = icmp uge i16 %a, %b
@@ -33,8 +38,9 @@ pub fn checked_sub_unsigned(a: u16, b: u16) -> Option<u16> {
3338// looking for no-wrap flags, we just need there to not be any masking.
3439
3540// 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)
3844#[ no_mangle]
3945pub fn checked_shl_unsigned ( a : u32 , b : u32 ) -> Option < u32 > {
4046 // CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -49,8 +55,9 @@ pub fn checked_shl_unsigned(a: u32, b: u32) -> Option<u32> {
4955}
5056
5157// 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)
5461#[ no_mangle]
5562pub fn checked_shr_unsigned ( a : u32 , b : u32 ) -> Option < u32 > {
5663 // CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -65,8 +72,9 @@ pub fn checked_shr_unsigned(a: u32, b: u32) -> Option<u32> {
6572}
6673
6774// 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)
7078#[ no_mangle]
7179pub fn checked_shl_signed ( a : i32 , b : u32 ) -> Option < i32 > {
7280 // CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -81,8 +89,9 @@ pub fn checked_shl_signed(a: i32, b: u32) -> Option<i32> {
8189}
8290
8391// 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)
8695#[ no_mangle]
8796pub fn checked_shr_signed ( a : i32 , b : u32 ) -> Option < i32 > {
8897 // CHECK-DAG: %[[IS_SOME:.+]] = icmp ult i32 %b, 32
@@ -97,8 +106,9 @@ pub fn checked_shr_signed(a: i32, b: u32) -> Option<i32> {
97106}
98107
99108// 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)
102112#[ no_mangle]
103113pub fn checked_add_one_unwrap_unsigned ( x : u32 ) -> u32 {
104114 // CHECK: %[[IS_MAX:.+]] = icmp eq i32 %x, -1
0 commit comments