diff options
author | Erik Desjardins <erikdesjardinspublic@gmail.com> | 2021-11-26 16:25:08 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2021-11-26 16:48:33 -0500 |
commit | 53b00b821582a95c5186bd76e7e7d12d2697a630 (patch) | |
tree | b158357e0ecb241d3d213497d03e70f455653716 /llvm/lib/CodeGen/ModuloSchedule.cpp | |
parent | 06f1d63cb16c4d7ec66eac3cdb6ae1f53aee5450 (diff) | |
download | llvm-53b00b821582a95c5186bd76e7e7d12d2697a630.zip llvm-53b00b821582a95c5186bd76e7e7d12d2697a630.tar.gz llvm-53b00b821582a95c5186bd76e7e7d12d2697a630.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp')
0 files changed, 0 insertions, 0 deletions