Closed
Description
Hi all, I am an LLVM developer working on the middle-end optimizations.
Recently I found an anti-pattern in some Rust applications from my benchmark. All of them come from hashbrown::raw::RawTableInner::free_buckets
:
Lines 3290 to 3294 in 274c7bb
LLVM IR:
define i32 @src(i32 %x, i32 %y) {
%res = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %x, i32 %y)
%ov = extractvalue { i32, i1 } %res, 1
%nowrap = xor i1 %ov, true
tail call void @llvm.assume(i1 %nowrap)
%val = extractvalue { i32, i1 } %res, 0
ret i32 %val
}
define i32 @tgt(i32 %x, i32 %y) {
%res = mul nuw i32 %x, %y
ret i32 %res
}
Alive2: https://alive2.llvm.org/ce/z/YBRjxc
Currently LLVM cannot use the knowledge from a never-overflow assumption. I have a draft patch for the fold and it enables more optimizations in downstream users of hashbrown
. But I am not willing to do an application-specific optimization in LLVM. So I file this issue to see whether we can fix it in hashbrown
.
Metadata
Metadata
Assignees
Labels
No labels