[PATCH] D114882: [PatternMatch] create and use matcher for 'not' that excludes undef elements

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 11:08:57 PST 2021


rampitec accepted this revision.
rampitec added a comment.

LGTM. Comment about commuted xor would be handy.



================
Comment at: llvm/include/llvm/IR/PatternMatch.h:2295-2298
+    if (m_Xor(m_Value(X), m_APIntForbidUndef(C)).match(V) && C->isAllOnes())
+      return Val.match(X);
+    if (m_Xor(m_APIntForbidUndef(C), m_Value(X)).match(V) && C->isAllOnes())
+      return Val.match(X);
----------------
spatel wrote:
> lebedev.ri wrote:
> > ?
> That's how I originally implemented it. :)
> 
> But that mismatched on the unit test that I created. In that test, the other operand is a zero constant with no undefs. So the commutative matcher matched the zero constant in that example as `C` and then failed the subsequent `isAllOnes` check.
> 
> It seems unlikely that we'd see something like that (should get constant-folded before we see it) in the optimizer, but it's still possible in general usage?
Sounds like a good thing to leave comment here. I also thought about m_c_Xor.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114882/new/

https://reviews.llvm.org/D114882



More information about the llvm-commits mailing list