[llvm] [InstCombine] Add combines for unsigned comparison of absolute value to constant (PR #172021)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 24 07:56:07 PST 2025
================
@@ -7602,6 +7602,51 @@ Instruction *InstCombinerImpl::foldICmpCommutative(CmpPredicate Pred,
}
}
+ // abs(X) u> K --> K >= 0 ? `X + K u> 2 * K` : `false`
+ // If abs(INT_MIN) is poison:
+ // abs(X) u< K --> K >= 1 ? `X + (K - 1) u<= 2 * (K - 1)` : K != 0
+ {
+ Value *X;
+ ConstantInt *C, *K;
+ bool Frozen = false;
+ if ((match(Op0,
+ m_Intrinsic<Intrinsic::abs>(m_Value(X), m_ConstantInt(C))) ||
+ (Frozen = match(Op0, m_Freeze(m_Intrinsic<Intrinsic::abs>(
----------------
dtcxzyw wrote:
We don't care about this case. If there is a freeze instruction blocking pattern matching, we can push the freeze through the abs in the future. See also pushFreezeToPreventPoisonFromPropagating.
https://github.com/llvm/llvm-project/pull/172021
More information about the llvm-commits
mailing list