[PATCH] D125500: [ValueTracking] recognize sub X, (X % Y) as not overflowing

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 13 06:05:50 PDT 2022


spatel added a comment.

In D125500#3510991 <https://reviews.llvm.org/D125500#3510991>, @nikic wrote:

> LGTM
>
> There are a lot more cases we could handle here (at least for the unsigned case) -- in particular a lot of the cases starting at https://github.com/llvm/llvm-project/blob/6d53d35efd3b876d2cc70a776fb168d6debfeba5/llvm/lib/Analysis/InstructionSimplify.cpp#L3023 are relevant. We have quite a few operations (urem, udiv, shr, and) that are non-increasing functions, often of both operands. Though I'm also not sure whether its worthwhile to try particularly hard to infer nuw here.

Yes, we also miss cases where an existing `nuw` could be used to simplify patterns with those ops:
https://alive2.llvm.org/ce/z/UFHE5_

I'll put a TODO comment in there.


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

https://reviews.llvm.org/D125500



More information about the llvm-commits mailing list