[PATCH] D138853: [InstSimplify] Fold !(X || Y) && X --> false
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 29 06:02:28 PST 2022
spatel added inline comments.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4567-4568
+ // !(X || Y) && X --> false (commuted 2 ways)
+ if (match(Cond, m_Not(m_LogicalOr(m_Value(X), m_Value(Y)))) &&
+ (TrueVal == X || TrueVal == Y))
+ return ConstantInt::getFalse(Cond->getType());
----------------
Shorten:
if (match(Cond, m_Not(m_c_LogicalOr(m_Specific(TrueVal), m_Value()))))
================
Comment at: llvm/test/Transforms/InstSimplify/select-logical.ll:190
define i1 @logical_or_not_and_comute_or(i1 %x, i1 %y) {
; CHECK-LABEL: @logical_or_not_and_comute_or(
----------------
typo: comute -> commute
================
Comment at: llvm/test/Transforms/InstSimplify/select-logical.ll:223
%not = xor <3 x i1> %l.and, <i1 true, i1 true, i1 true>
%r = select <3 x i1> %not, <3 x i1> %x, <3 x i1> <i1 true, i1 false, i1 false>
ret <3 x i1> %r
----------------
The FalseVal of `%r` is not zero, so this is not showing what the comment describes. This might need a TODO if we don't match the first select as logical-or?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138853/new/
https://reviews.llvm.org/D138853
More information about the llvm-commits
mailing list