<div dir="ltr">Hi David,<div>Apologies for the bad variable name in the test cases. I somehow missed the comments. Will update the test case along with next patch.</div><div>Regards</div><div>Karthik Bhat</div><div><br></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 14, 2014 at 4:54 AM, Jonathan Roelofs <span dir="ltr"><<a href="mailto:jonathan@codesourcery.com" target="_blank">jonathan@codesourcery.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
<br>
On 8/13/14, 5:05 PM, David Majnemer wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
On Tue, Aug 12, 2014 at 10:13 PM, Karthik Bhat <<a href="mailto:kv.bhat@samsung.com" target="_blank">kv.bhat@samsung.com</a><br></div><div class="">
<mailto:<a href="mailto:kv.bhat@samsung.com" target="_blank">kv.bhat@samsung.com</a>>> wrote:<br>
<br>
Author: karthik<br>
Date: Wed Aug 13 00:13:14 2014<br>
New Revision: 215524<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=215524&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project?rev=215524&view=rev</a><br>
Log:<br>
InstCombine: Combine (xor (or %a, %b) (xor %a, %b)) to (add %a, %b)<br>
</div></blockquote>
s/add/and/<br>
<br>
Unfortunately too late to fix as it's in the commit message.<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
Correctness proof of the transform using CVC3-<br>
<br>
$ cat t.cvc<br>
A, B : BITVECTOR(32);<br>
QUERY BVXOR(A | B, BVXOR(A,B) ) = A & B;<br>
<br>
$ cvc3 t.cvc<br>
Valid.<br>
<br>
<br>
Modified:<br>
llvm/trunk/lib/Transforms/<u></u>InstCombine/<u></u>InstCombineAndOrXor.cpp<br>
llvm/trunk/test/Transforms/<u></u>InstCombine/or-xor.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/<u></u>InstCombine/<u></u>InstCombineAndOrXor.cpp<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=215524&r1=215523&r2=215524&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/lib/<u></u>Transforms/InstCombine/<u></u>InstCombineAndOrXor.cpp?rev=<u></u>215524&r1=215523&r2=215524&<u></u>view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/lib/Transforms/<u></u>InstCombine/<u></u>InstCombineAndOrXor.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<u></u>InstCombine/<u></u>InstCombineAndOrXor.cpp Wed Aug 13<br>
00:13:14 2014<br>
@@ -2508,6 +2508,18 @@ Instruction *InstCombiner::visitXor(Bina<br>
if ((A == C && B == D) || (A == D && B == C))<br>
return BinaryOperator::CreateXor(A, B);<br>
}<br>
+ // (A ^ B)^(A | B) -> A & B<br>
+ if (match(Op0I, m_Xor(m_Value(A), m_Value(B))) &&<br>
+ match(Op1I, m_Or(m_Value(C), m_Value(D)))) {<br>
+ if ((A == C && B == D) || (A == D && B == C))<br>
+ return BinaryOperator::CreateAnd(A, B);<br>
+ }<br>
+ // (A | B)^(A ^ B) -> A & B<br>
+ if (match(Op0I, m_Or(m_Value(A), m_Value(B))) &&<br>
+ match(Op1I, m_Xor(m_Value(C), m_Value(D)))) {<br>
+ if ((A == C && B == D) || (A == D && B == C))<br>
+ return BinaryOperator::CreateAnd(A, B);<br>
+ }<br>
// (A & B) ^ (A ^ B) -> (A | B)<br>
if (match(Op0I, m_And(m_Value(A), m_Value(B))) &&<br>
match(Op1I, m_Xor(m_Specific(A), m_Specific(B))))<br>
<br>
Modified: llvm/trunk/test/Transforms/<u></u>InstCombine/or-xor.ll<br>
URL:<br>
<a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/or-xor.ll?rev=215524&r1=215523&r2=215524&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<u></u>project/llvm/trunk/test/<u></u>Transforms/InstCombine/or-xor.<u></u>ll?rev=215524&r1=215523&r2=<u></u>215524&view=diff</a><br>
==============================<u></u>==============================<u></u>==================<br>
--- llvm/trunk/test/Transforms/<u></u>InstCombine/or-xor.ll (original)<br>
+++ llvm/trunk/test/Transforms/<u></u>InstCombine/or-xor.ll Wed Aug 13 00:13:14 2014<br>
@@ -136,3 +136,14 @@ define i32 @test13(i32 %x, i32 %y) {<br>
; CHECK-NEXT: %and = and i32 %x, %y<br>
; CHECK-NEXT: ret i32 %and<br>
}<br>
+<br>
+; ((x | y) ^ (x ^ y)) -> (x & y)<br>
+define i32 @test15(i32 %x, i32 %y) {<br>
+ %1 = xor i32 %y, %x<br>
+ %2 = or i32 %y, %x<br>
+ %3 = xor i32 %2, %1<br>
+ ret i32 %3<br>
+; CHECK-LABEL: @test15(<br>
+; CHECK-NEXT: %1 = and i32 %y, %x<br>
+; CHECK-NEXT: ret i32 %1<br>
<br>
<br>
I LGTM'd this differential under the understanding that you would clean up the<br>
variable names used: <a href="http://reviews.llvm.org/D4866#inline-40056" target="_blank">http://reviews.llvm.org/D4866#<u></u>inline-40056</a><br>
<br>
Please fix test15.<br>
<br>
+}<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br></div></div>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a> <mailto:<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.<u></u>edu</a>><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><div class=""><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
<br>
</div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Jon Roelofs<br>
<a href="mailto:jonathan@codesourcery.com" target="_blank">jonathan@codesourcery.com</a><br>
CodeSourcery / Mentor Embedded</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>