[llvm] Remove simplifySelectInst/foldSelectWithBinaryOp (PR #118913)
Yihang Liu via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 18:30:34 PST 2024
https://github.com/glyh created https://github.com/llvm/llvm-project/pull/118913
As mentioned in https://github.com/llvm/llvm-project/issues/118815, the purpose of this simplification is superseded by https://github.com/llvm/llvm-project/pull/100878, so we should have it deleted.
>From 15e8e49ce2b5527f0da1f5056e3a237cf8539916 Mon Sep 17 00:00:00 2001
From: glyh <lyhokia at gmail.com>
Date: Fri, 6 Dec 2024 10:27:31 +0800
Subject: [PATCH] Remove simplifySelectInst/foldSelectWithBinaryOp that is
superseded by #100878
---
llvm/lib/Analysis/InstructionSimplify.cpp | 45 -----------------------
1 file changed, 45 deletions(-)
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 05e8f5761c13cf..62edea38745b13 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -81,48 +81,6 @@ static Value *simplifyInstructionWithOperands(Instruction *I,
const SimplifyQuery &SQ,
unsigned MaxRecurse);
-static Value *foldSelectWithBinaryOp(Value *Cond, Value *TrueVal,
- Value *FalseVal) {
- BinaryOperator::BinaryOps BinOpCode;
- if (auto *BO = dyn_cast<BinaryOperator>(Cond))
- BinOpCode = BO->getOpcode();
- else
- return nullptr;
-
- CmpInst::Predicate ExpectedPred;
- if (BinOpCode == BinaryOperator::Or) {
- ExpectedPred = ICmpInst::ICMP_NE;
- } else if (BinOpCode == BinaryOperator::And) {
- ExpectedPred = ICmpInst::ICMP_EQ;
- } else
- return nullptr;
-
- // %A = icmp eq %TV, %FV
- // %B = icmp eq %X, %Y (and one of these is a select operand)
- // %C = and %A, %B
- // %D = select %C, %TV, %FV
- // -->
- // %FV
-
- // %A = icmp ne %TV, %FV
- // %B = icmp ne %X, %Y (and one of these is a select operand)
- // %C = or %A, %B
- // %D = select %C, %TV, %FV
- // -->
- // %TV
- Value *X, *Y;
- if (!match(Cond,
- m_c_BinOp(m_c_SpecificICmp(ExpectedPred, m_Specific(TrueVal),
- m_Specific(FalseVal)),
- m_SpecificICmp(ExpectedPred, m_Value(X), m_Value(Y)))))
- return nullptr;
-
- if (X == TrueVal || X == FalseVal || Y == TrueVal || Y == FalseVal)
- return BinOpCode == BinaryOperator::Or ? TrueVal : FalseVal;
-
- return nullptr;
-}
-
/// For a boolean type or a vector of boolean type, return false or a vector
/// with every element false.
static Constant *getFalse(Type *Ty) { return ConstantInt::getFalse(Ty); }
@@ -4994,9 +4952,6 @@ static Value *simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
if (Value *V = simplifySelectWithFCmp(Cond, TrueVal, FalseVal, Q, MaxRecurse))
return V;
- if (Value *V = foldSelectWithBinaryOp(Cond, TrueVal, FalseVal))
- return V;
-
std::optional<bool> Imp = isImpliedByDomCondition(Cond, Q.CxtI, Q.DL);
if (Imp)
return *Imp ? TrueVal : FalseVal;
More information about the llvm-commits
mailing list