<div dir="ltr">Following up here with a link that Nuno posted in the D29774 review, so I'm less likely to lose the hint. :)<br><br>"You can see the list of predicates/functions here (the syntax highlighting code):<br> <a href="https://github.com/nunoplopes/alive/blob/newsema/rise4fun/language" rel="noreferrer" target="_blank">https://github.com/<wbr>nunoplopes/alive/blob/newsema/<wbr>rise4fun/language</a><br>"<br><br>Example:<br><a href="http://rise4fun.com/Alive/plF" target="_blank">http://rise4fun.com/Alive/plF</a><br><br>Name: slt_overflow<br>Pre: !WillNotOverflowSignedSub(C2, C1)<br>%a = add nsw i8 %x, C1<br>%b = icmp slt %a, C2<br>  =><br>%b = icmp sge C2, 0<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 8, 2017 at 12:26 PM, Nuno Lopes <span dir="ltr"><<a href="mailto:nuno.lopes@ist.utl.pt" target="_blank">nuno.lopes@ist.utl.pt</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It's very on topic, certainly. We've ported more than 300 InstCombine patterns to Alive ourselves.<br>
Right now the C++ code generation is not great. Alive produces a linear search through the patterns, similar to how InstCombine works today.<br>
It's on my todo list to improve this part of Alive; I just didn't have time to do it yet.  If this year I manage to get an intern with experience on graph rewriting, we'll get it done (or try, at least)! :)<span class="HOEnZb"><font color="#888888"><br>
<br>
Nuno</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
-----Original Message-----<br>
From: Bryant Wong<br>
Sent: Friday, January 6, 2017 7:29 PM<br>
To: Sanjay Patel ; <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
Cc: Nuno Lopes ; John Regehr<br>
Subject: Re: [llvm-dev] Alive now available online<br>
<br>
<br>
Not sure how off-topic this is, but should we consider/have we considered porting our InstCombines to Alive? The PLDI '15 paper even demos C++ extraction from Alive theorems. I think it'd be a small step from that to extracting tightly optimized VM code, not unlike what Tablegen emits. Everything would be so clean and readable and organized. And edge cases can still be handled manually, like ISel.<br>
<br>
<br>
<br>
On Fri, Jan 6, 2017 at 9:38 AM, Sanjay Patel <<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a>> wrote:<br>
<br>
<br>
<br>
On Fri, Jan 6, 2017 at 2:30 AM, Nuno Lopes <<a href="mailto:nuno.lopes@ist.utl.pt" target="_blank">nuno.lopes@ist.utl.pt</a>> wrote:<br>
<br>
<br>
Hi Sanjay,<br>
<br>
<br>
<br>
You used Alive correctly, of course :)<br>
<br>
At this moment we cannot give you the best precondition. It’s on the todo list, but it’s not even started yet. It’s a much harder problem to solve. We do have a mode to compute the best set of nsw/nuw/exact attributes in the transformed expression, but it’s not enabled on the web interface yet (InstCombine was missing quite a few cases last time I checked).<br>
<br>
<br>
<br>
I played a bit with your example and realized that it doesn’t even need a precondition :)  Check this out: <a href="http://rise4fun.com/Alive/j" rel="noreferrer" target="_blank">http://rise4fun.com/Alive/j</a><br>
<br>
(btw, > is signed comparison, and u> is unsigned).<br>
<br>
<br>
<br>
<br>
<br>
<br>
Nice! I'll draft a patch for the transform.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Nuno<br>
<br>
<br>
<br>
<br>
<br>
From: Sanjay Patel [mailto:<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a><wbr>]<br>
Sent: 6 de janeiro de 2017 00:35<br>
To: Nuno Lopes <<a href="mailto:nuno.lopes@ist.utl.pt" target="_blank">nuno.lopes@ist.utl.pt</a>><br>
Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; John Regehr <<a href="mailto:regehr@cs.utah.edu" target="_blank">regehr@cs.utah.edu</a>>; <a href="mailto:3.14472%2Breviews.llvm.org@gmail.com" target="_blank">3.14472+reviews.llvm.org@gmail<wbr>.com</a><br>
Subject: Re: [llvm-dev] Alive now available online<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Hi Nuno,<br>
<br>
<br>
<br>
This is great. I just stumbled onto a problem that's similar to the one that Bryant solved in:<br>
<a href="https://reviews.llvm.org/rL285729" rel="noreferrer" target="_blank">https://reviews.llvm.org/rL285<wbr>729</a><br>
<br>
define i1 @foo(i32 %x) {<br>
 %shl = shl nsw i32 %x, 4<br>
 %cmp = icmp sgt i32 %shl, 1<br>
 ret i1 %cmp<br>
}<br>
<br>
<br>
<br>
(For more background, see PR30773 - <a href="https://llvm.org/bugs/show_bug.cgi?id=30773" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug<wbr>.cgi?id=30773</a> )<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
So I'm staring at that wondering why instcombine can't see that it's really just:<br>
define i1 @foo(i32 %x) {<br>
 %cmp = icmp sgt i32 %x, 0<br>
 ret i1 %cmp<br>
}<br>
<br>
<br>
<br>
As a first hack, I did this:<br>
<a href="http://rise4fun.com/Alive/qG" rel="noreferrer" target="_blank">http://rise4fun.com/Alive/qG</a><br>
<br>
<br>
<br>
<br>
Name: sgt<br>
Pre: C0 > 0<br>
%a = shl nsw i8 %x, C1<br>
%b = icmp sgt %a, C0<br>
 =><br>
%b = icmp sgt %x, (C0 >> C1)<br>
<br>
<br>
<br>
...and success! Assuming I used Alive correctly. :)<br>
<br>
But is there a way to tell if I've chosen the most liberal constraint? Ie, is C0 > 0 the best pre-condition?<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Thu, Jan 5, 2017 at 3:42 PM, Nuno Lopes via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
<br>
<br>
<br>
Hi,<br>
<br>
Just a short email to announce that Alive is now available online: <a href="http://rise4fun.com/Alive" rel="noreferrer" target="_blank">http://rise4fun.com/Alive</a><br>
<br>
The site includes a few examples (both correct and buggy). You can also create a "permalink" to send the proof to someone else.<br>
<br>
The execution time is limited to 30 seconds for now.  You may want to constrain the operand's types if the tool times out, for example.<br>
<br>
The service is still in tests.  Please let me know if you run into problems and/or if you have comments or feature requests.<br>
<br>
Nuno<br>
<br>
P.S.: The semantics implemented in this release is the one I've presented at the last LLVM dev meeting.  I've kept undef for now, though, but there's a poison value.  There's (very) limited support for branches as well.<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a> <br>
</div></div></blockquote></div><br></div>