<div dir="ltr">No, I haven't looked at VRP yet, so I don't know why it's not handled there. I was assuming that since InstSimplify/InstCombine already have a large chunk of folds for the and/or variants, it would make sense to also handle xor there. <br><br>I have a patch in progress that would handle these cases using the existing code (truth tables!). Let me post that for review and see what you think about it.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 18, 2017 at 5:11 PM, Davide Italiano <span dir="ltr"><<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, May 18, 2017 at 4:10 PM, Davide Italiano <<a href="mailto:davide@freebsd.org">davide@freebsd.org</a>> wrote:<br>
> On Thu, May 18, 2017 at 3:47 PM, Sanjay Patel via llvm-commits<br>
> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>> Author: spatel<br>
>> Date: Thu May 18 17:47:57 2017<br>
>> New Revision: 303387<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=303387&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=303387&view=rev</a><br>
>> Log:<br>
>> [InstCombine] add more tests for xor-of-icmps; NFC<br>
>><br>
>> Modified:<br>
>> llvm/trunk/test/Transforms/<wbr>InstCombine/set.ll<br>
>><br>
>> Modified: llvm/trunk/test/Transforms/<wbr>InstCombine/set.ll<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/set.ll?rev=303387&r1=303386&r2=303387&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>Transforms/InstCombine/set.ll?<wbr>rev=303387&r1=303386&r2=<wbr>303387&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- llvm/trunk/test/Transforms/<wbr>InstCombine/set.ll (original)<br>
>> +++ llvm/trunk/test/Transforms/<wbr>InstCombine/set.ll Thu May 18 17:47:57 2017<br>
>> @@ -175,6 +175,36 @@ define i1 @xor_of_icmps(i64 %a) {<br>
>> ret i1 %xor<br>
>> }<br>
>><br>
>> +; FIXME: This is also equivalent to the previous test.<br>
>> +<br>
>> +define i1 @xor_of_icmps_commute(i64 %a) {<br>
>> +; CHECK-LABEL: @xor_of_icmps_commute(<br>
>> +; CHECK-NEXT: [[B:%.*]] = icmp sgt i64 %a, 0<br>
>> +; CHECK-NEXT: [[C:%.*]] = icmp eq i64 %a, 1<br>
>> +; CHECK-NEXT: [[XOR:%.*]] = xor i1 [[B]], [[C]]<br>
>> +; CHECK-NEXT: ret i1 [[XOR]]<br>
>> +;<br>
>> + %b = icmp sgt i64 %a, 0<br>
>> + %c = icmp eq i64 %a, 1<br>
>> + %xor = xor i1 %b, %c<br>
>> + ret i1 %xor<br>
>> +}<br>
>> +<br>
>> +; FIXME: This is (a != 5).<br>
>> +<br>
>> +define i1 @xor_of_icmps_folds_more(i64 %a) {<br>
>> +; CHECK-LABEL: @xor_of_icmps_folds_more(<br>
>> +; CHECK-NEXT: [[B:%.*]] = icmp sgt i64 %a, 4<br>
>> +; CHECK-NEXT: [[C:%.*]] = icmp slt i64 %a, 6<br>
>> +; CHECK-NEXT: [[XOR:%.*]] = xor i1 [[B]], [[C]]<br>
>> +; CHECK-NEXT: ret i1 [[XOR]]<br>
>> +;<br>
><br>
> You can start from having these in `-instcombine`, but these (and<br>
> other tests) seems like a VRP problem to me. I haven't studied this<br>
> carefully, but I wonder why we don't catch these. Have you tried to<br>
> evaluate why our VRP pass doesn't handle these?<br>
><br>
> --<br>
> Davide<br>
<br>
</div></div>Not necessarily complaining about having these as combiners, but I'd<br>
first like to understand why we don't catch these somewhere else :)<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
</font></span></blockquote></div><br></div>