[PATCH] D99674: [InstCombine] Conditionally fold select i1 into and/or
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 05:51:34 PDT 2021
spatel added a comment.
Apart from being unsafe, this pair of transforms also goes against the usual rule of not creating more instructions than we started with:
// select a, false, b -> select !a, b, false
if (match(TrueVal, m_Zero())) {
Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName());
return SelectInst::Create(NotCond, FalseVal, Zero);
}
// select a, b, true -> select !a, true, b
if (match(FalseVal, m_One())) {
Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName());
return SelectInst::Create(NotCond, One, TrueVal);
}
I think we should just delete those (either with or without reverting this patch). We can add a safe transform for "select i1 %x, i1 0, i1 1 --> xor i1 %x, -1" to avoid a regression:
https://alive2.llvm.org/ce/z/Bhdy-Y
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99674/new/
https://reviews.llvm.org/D99674
More information about the llvm-commits
mailing list