-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Remove simplifySelectInst/foldSelectWithBinaryOp #118913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-llvm-analysis Author: Yihang Liu (glyh) ChangesAs mentioned in #118815, the purpose of this simplification is superseded by #100878, so we should have it deleted. Full diff: https://github.com/llvm/llvm-project/pull/118913.diff 1 Files Affected:
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;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the failing tests in llvm/test/Transforms/InstSimplify. These probably need to be moved to InstCombine to work now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@glyh Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
As mentioned in #118815, the purpose of this simplification is superseded by #76621, so we should have it deleted.