[PATCH] D114882: [PatternMatch] create and use matcher for 'not' that excludes undef elements
    Sanjay Patel via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Dec  1 08:49:39 PST 2021
    
    
  
spatel added inline comments.
================
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);
----------------
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?
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114882/new/
https://reviews.llvm.org/D114882
    
    
More information about the llvm-commits
mailing list