[PATCH] D140798: [InstCombine] Fold zero check followed by decrement to usub.sat

Tim Neumann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 06:50:20 PST 2023


TimNN added a comment.

Just as a heads-up, this regresses one of Rust's codegen tests: `fn check_foo2` in [`issue-45222.rs`](https://github.com/rust-lang/rust/blob/master/src/test/codegen/issue-45222.rs) is no longer being constant-folded, AFAICT because `IndVarSimplifyPass` no longer works on the `%a = tail call i64 @llvm.usub.sat.i64(i64 %b, i64 1)` generated by this patch (instead of `%a = add i64 %b, -1` without this patch).

The full module IR is at https://gist.github.com/TimNN/e9a762026083ff265bdccbbcb34be956 (sorry, not minimized). Running it through `opt -O3` without this patch constant-folds the loop, with this patch the loop remains.

I don't know if this is significant enough to warrant reverting the patch (I'm guessing not). Let me know if you have suggestions on how to proceed. (Is this a problem with the transform or does `IndVarSimplifyPass` need to become smarter?)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140798/new/

https://reviews.llvm.org/D140798



More information about the llvm-commits mailing list