I fixed some poison-safety violations on related patterns in InstCombine and noticed that we missed adding nsw/nuw on them, so this adds clauses to the underlying analysis for that.
We need the undef input restriction to make this safe according to Alive2:
https://alive2.llvm.org/ce/z/48g9K8
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
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.
Comment Actions
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.