[llvm] [InstCombine] Teach foldSelectOpOp about samesign (PR #122723)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 13:57:50 PST 2025
================
@@ -428,10 +428,10 @@ 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;
+ bool Swapped = ICmpInst::isRelational(FPred) &&
+ CmpPredicate::getMatching(
+ TPred, ICmpInst::getSwappedCmpPredicate(FPred));
+ if (CmpPredicate::getMatching(TPred, FPred) || Swapped) {
----------------
nikic wrote:
We use TPred below, instead of the matching predicate. Sorry for missing this obvious bug :(
https://github.com/llvm/llvm-project/pull/122723
More information about the llvm-commits
mailing list