- Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization
Description
The probably never comes up in C++, but in Rust people can easily end up there from things that boil down to
x.checked_add(y).unwrap_unchecked()Proof: https://alive2.llvm.org/ce/z/m-n_PG
define i32 @src(i32 noundef %x, i32 noundef %y) noundef { start: %#0 = sadd_overflow i32 noundef %x, noundef %y %_7.1 = extractvalue {i32, i1, i24} %#0, 1 %_10 = xor i1 %_7.1, 1 %_7.0 = extractvalue {i32, i1, i24} %#0, 0 assume i1 %_10 ret i32 %_7.0 } => define i32 @tgt(i32 noundef %x, i32 noundef %y) noundef { start: %r = add nsw i32 noundef %x, noundef %y ret i32 %r } Transformation seems to be correct!And of course the uadd_overflow+assume → add nuw too.
Metadata
Metadata
Assignees
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization