[PATCH] D86395: InstCombine transform pattern "(~A & B) ^ A -> (A | B)" added
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 14:16:57 PDT 2020
spatel added a comment.
The tests should be pre-committed with current CHECK lines (ie, without this patch), so we just see the diffs - and can confirm that the tests actually represent the patterns shown in the test comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3357
+ // (~A & B) ^ A --> (A | B)
+ if (match(Op0, m_c_And(m_Not(m_Value(A)), m_Value(B))) &&
+ match(Op1, m_Specific(A)))
----------------
What about the case where the `and` is Op1?
================
Comment at: llvm/test/Transforms/InstCombine/xor-or.ll:21
+ %4 = and i32 %3, %1
+ %5 = xor i32 %4, %0
+ ret i32 %5
----------------
This test doesn't match the comment.
You need something like this:
```
define i32 @test2(i32 %p, i32 %y) {
%x = add i32 %p, 42 ; thwart complexity-based canonicalization
%n = xor i32 %x, -1
%a = and i32 %n, %y
%r = xor i32 %x, %a
ret i32 %r
}
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86395/new/
https://reviews.llvm.org/D86395
More information about the llvm-commits
mailing list