[PATCH] D138700: [InstSimplify] Fold (X || Y) ? false : X --> false
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 29 05:43:28 PST 2022
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.
LGTM - see inline for code suggestion.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4559
Value *X, *Y;
+ if (match(Cond, m_LogicalOr(m_Value(X), m_Value(Y)))) {
+ // (X || Y) ? false : X --> false (commuted 2 ways)
----------------
Use m_c_LogicalOr() and m_Specific() to make the code shorter. We do not need to capture X/Y:
if (match(Cond, m_c_LogicalOr(m_Specific(FalseVal), m_Value())) &&
match(TrueVal, m_ZeroInt()))
return ConstantInt::getFalse(Cond->getType());
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138700/new/
https://reviews.llvm.org/D138700
More information about the llvm-commits
mailing list