[InstSimplify] Fold X {lshr,udiv} C <u X --> true for nonzero X, non-identity C
This eliminates the bounds check in Rust code like pub fn mid(data: &[i32]) -> i32 { if data.is_empty() { return 0; } return data[data.len()/2]; } (from https://blog.sigplan.org/2021/11/18/undefined-behavior-deserves-a-better-reputation/) Alive proofs: lshr https://alive2.llvm.org/ce/z/nyTu8D udiv https://alive2.llvm.org/ce/z/CNUZH7 Differential Revision: https://reviews.llvm.org/D114279
Loading
Please sign in to comment