[llvm] Reland [InstCombine] Teach foldSelectOpOp about samesign (PR #124320)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 25 13:20:31 PST 2025
================
@@ -428,16 +428,18 @@ Instruction *InstCombinerImpl::foldSelectOpOp(SelectInst &SI, Instruction *TI,
CmpPredicate TPred, FPred;
if (match(TI, m_ICmp(TPred, m_Value(), m_Value())) &&
match(FI, m_ICmp(FPred, m_Value(), m_Value()))) {
- // FIXME: Use CmpPredicate::getMatching here.
- CmpInst::Predicate T = TPred, F = FPred;
- if (T == F || T == ICmpInst::getSwappedCmpPredicate(F)) {
- bool Swapped = T != F;
+ auto P = CmpPredicate::getMatching(TPred, FPred);
+ bool Swapped = !P;
+ if (Swapped)
+ P = CmpPredicate::getMatching(TPred,
+ ICmpInst::getSwappedCmpPredicate(FPred));
+ if (P) {
----------------
nikic wrote:
This is pretty convoluted. I'd implement this by calling a lambda two times instead (once swapped).
https://github.com/llvm/llvm-project/pull/124320
More information about the llvm-commits
mailing list