[llvm] [InstCombine] Fold negation of unsigned div of non-negatives (PR #84951)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 09:34:56 PDT 2024
================
@@ -2062,6 +2062,25 @@ static Instruction *foldSubOfMinMax(BinaryOperator &I,
return nullptr;
}
+/// Fold `sub 0, (udiv nneg X, nneg C)` into `sdiv nneg X, -C`
+static Instruction *foldNegationOfUDivOfNonNegatives(BinaryOperator &I,
+ InstCombinerImpl &IC) {
+ Value *RHS = I.getOperand(1);
+ Value *X;
+ Constant *C;
+
+ const auto &SQ = IC.getSimplifyQuery().getWithInstruction(&I);
+ if (match(RHS, m_OneUse(m_UDiv(m_Value(X), m_Constant(C)))) &&
+ isKnownNonNegative(X, SQ) && isKnownNonNegative(C, SQ)) {
----------------
goldsteinn wrote:
I don't think we look past `bitcast` when computing known bits for dom conditions.
https://github.com/llvm/llvm-project/pull/84951
More information about the llvm-commits
mailing list