Skip to content

Commit a710de9

Browse files
authored
Rollup merge of #123808 - maurer:nuw-nsw-trunc, r=durin42
codegen tests: Tolerate `nuw` `nsw` on `trunc` llvm/llvm-project#87910 infers `nuw` and `nsw` on some `trunc` instructions we're doing `FileCheck` on. Tolerate but don't require them to support both release and head LLVM. `@rustbot` label: +llvm-main cc `@durin42`
2 parents 08ebea2 + e70cf01 commit a710de9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/codegen/ascii-char.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn unwrap_digit_from_remainder(v: u32) -> AsciiChar {
1212
// CHECK-NOT: panic
1313

1414
// CHECK: %[[R:.+]] = urem i32 %v, 10
15-
// CHECK-NEXT: %[[T:.+]] = trunc i32 %[[R]] to i8
15+
// CHECK-NEXT: %[[T:.+]] = trunc{{( nuw)?( nsw)?}} i32 %[[R]] to i8
1616
// CHECK-NEXT: %[[D:.+]] = or{{( disjoint)?}} i8 %[[T]], 48
1717
// CHECK-NEXT: ret i8 %[[D]]
1818

tests/codegen/unchecked_shifts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
2222

2323
// CHECK-DAG: %[[INRANGE:.+]] = icmp ult i32 %b, 16
2424
// CHECK-DAG: tail call void @llvm.assume(i1 %[[INRANGE]])
25-
// CHECK-DAG: %[[TRUNC:.+]] = trunc i32 %b to i16
25+
// CHECK-DAG: %[[TRUNC:.+]] = trunc{{( nuw)?( nsw)?}} i32 %b to i16
2626
// CHECK-DAG: shl i16 %a, %[[TRUNC]]
2727
a.unchecked_shl(b)
2828
}
@@ -54,7 +54,7 @@ pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 {
5454

5555
// CHECK-DAG: %[[INRANGE:.+]] = icmp ult i32 %b, 16
5656
// CHECK-DAG: tail call void @llvm.assume(i1 %[[INRANGE]])
57-
// CHECK-DAG: %[[TRUNC:.+]] = trunc i32 %b to i16
57+
// CHECK-DAG: %[[TRUNC:.+]] = trunc{{( nuw)?( nsw)?}} i32 %b to i16
5858
// CHECK-DAG: ashr i16 %a, %[[TRUNC]]
5959
a.unchecked_shr(b)
6060
}
@@ -94,7 +94,7 @@ pub unsafe fn unchecked_shl_u8_i128(a: u8, b: i128) -> u8 {
9494

9595
// CHECK-DAG: %[[INRANGE:.+]] = icmp ult i128 %b, 8
9696
// CHECK-DAG: tail call void @llvm.assume(i1 %[[INRANGE]])
97-
// CHECK-DAG: %[[TRUNC:.+]] = trunc i128 %b to i8
97+
// CHECK-DAG: %[[TRUNC:.+]] = trunc{{( nuw)?( nsw)?}} i128 %b to i8
9898
// CHECK-DAG: shl i8 %a, %[[TRUNC]]
9999
std::intrinsics::unchecked_shl(a, b)
100100
}
@@ -107,7 +107,7 @@ pub unsafe fn unchecked_shr_i8_u128(a: i8, b: u128) -> i8 {
107107

108108
// CHECK-DAG: %[[INRANGE:.+]] = icmp ult i128 %b, 8
109109
// CHECK-DAG: tail call void @llvm.assume(i1 %[[INRANGE]])
110-
// CHECK-DAG: %[[TRUNC:.+]] = trunc i128 %b to i8
110+
// CHECK-DAG: %[[TRUNC:.+]] = trunc{{( nuw)?( nsw)?}} i128 %b to i8
111111
// CHECK-DAG: ashr i8 %a, %[[TRUNC]]
112112
std::intrinsics::unchecked_shr(a, b)
113113
}

0 commit comments

Comments
 (0)