[llvm] [InstCombine] Fold `(icmp pred (trunc nuw/nsw X), C)` -> `(icmp pred X, (zext/sext C))` (PR #87935)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 09:14:00 PDT 2024


goldsteinn wrote:

> Generally fine, but before we start using trunc nuw/nsw in optimizations we need to perform some due diligence. Based on past experience, we very likely have folds that incorrectly preserve the nuw/nsw flag now.
> 
> Approach is basically 1. replace "trunc" with "trunc nuw" in existing tests, 2. check whether there are failures with alive2, 3. repeat with trunc nsw. Let me know if you would be interested in doing that...

Ill look into that. I would think the only way this really becomes an issue is if we have `replaceOperand` on a `trunc`. Any other use case we would erroneously preserve flags?

https://github.com/llvm/llvm-project/pull/87935


More information about the llvm-commits mailing list