[llvm] [InstCombine] Fold uadd.sat comparison using known operand relation (PR #212776)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 8 11:41:55 PDT 2026
================
@@ -4095,6 +4095,49 @@ Instruction *InstCombinerImpl::foldICmpBinOpWithConstant(ICmpInst &Cmp,
return foldICmpBinOpWithConstantViaTruthTable(Cmp, BO, C);
}
+/// Fold uadd.sat(X, C) <u C2 to X <u C2 - C when C2 >=u C is
+/// known to hold.
----------------
dtcxzyw wrote:
I don't think the non-constant case is interesting. There is no evidence that this pattern exists in real-world programs.
@ParkHanbum I don't really get what you want to improve in https://github.com/llvm/llvm-project/issues/169763. Can you please illustrate a concrete case?
For the constant case in `foldICmpUSubSatOrUAddSatWithConstant`, the only thing we can do is to defer the one-use check: https://godbolt.org/z/hsae4cWrc It is still profitable if `EquivOffset` is zero.
https://github.com/llvm/llvm-project/pull/212776
More information about the llvm-commits
mailing list