Rollup merge of #146732 - durin42:llvm-22-less-assumes, r=nikic

tests: relax expectations after llvm change 902ddda120a5

LLVM 22 is able to drop assumes that seem to not help further optimizations, which actually seems to dramatically _help_ further optimizations in some of our small test cases.

I'm a little unclear how to fix the last failure, in `tests/codegen-llvm/issues/issue-122600-ptr-discriminant-update.rs`:

```
-; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
+; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: readwrite, inaccessiblemem: write) uwtable
 define void ``@update(ptr`` noundef captures(none) %s) unnamed_addr #0 {
 start:
-  %_3.sroa.0.0.copyload = load i8, ptr %s, align 1
-  %0 = trunc nuw i8 %_3.sroa.0.0.copyload to i1
-  %1 = xor i1 %0, true
-  tail call void ``@llvm.assume(i1`` %1)
   store i8 1, ptr %s, align 1
   ret void
 }
```

I'm just not conversant enough in LLVM IR to follow the changes here.

``@rustbot`` label llvm-main
r? nikic
This commit is contained in:
Matthias Krüger 2025-09-27 21:25:57 +02:00 committed by GitHub
commit c772af78e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View file

@ -1,4 +1,7 @@
//@ compile-flags: -Copt-level=3
//@ revisions: new old
//@ [old] max-llvm-major-version: 21
//@ [new] min-llvm-version: 22
#![crate_type = "lib"]
@ -22,8 +25,8 @@ pub unsafe fn update(s: *mut State) {
// CHECK-NOT: memcpy
// CHECK-NOT: 75{{3|4}}
// CHECK: %[[TAG:.+]] = load i8, ptr %s, align 1
// CHECK-NEXT: trunc nuw i8 %[[TAG]] to i1
// old: %[[TAG:.+]] = load i8, ptr %s, align 1
// old-NEXT: trunc nuw i8 %[[TAG]] to i1
// CHECK-NOT: load
// CHECK-NOT: store

View file

@ -1,4 +1,7 @@
//@ compile-flags: -Copt-level=3
//@ revisions: new old
//@ [old] max-llvm-major-version: 21
//@ [new] min-llvm-version: 22
#![crate_type = "lib"]
@ -7,7 +10,7 @@
pub fn noop(v: &mut Vec<u8>) {
// CHECK-NOT: grow_one
// CHECK-NOT: call
// CHECK: tail call void @llvm.assume
// old: tail call void @llvm.assume
// CHECK-NOT: grow_one
// CHECK-NOT: call
// CHECK: {{ret|[}]}}

View file

@ -1,4 +1,7 @@
//@ compile-flags: -Copt-level=3
//@ revisions: new old
//@ [old] max-llvm-major-version: 21
//@ [new] min-llvm-version: 22
#![crate_type = "lib"]
@ -8,7 +11,7 @@ use std::collections::VecDeque;
// CHECK-LABEL: @noop_back(
pub fn noop_back(v: &mut VecDeque<u8>) {
// CHECK-NOT: grow
// CHECK: tail call void @llvm.assume
// old: tail call void @llvm.assume
// CHECK-NOT: grow
// CHECK: ret
if let Some(x) = v.pop_back() {