<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">My apologies, you're right; I was comparing against an older version of Clang that didn't do this.<div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class=""> - CL</span>

</div>
<br class=""><div style=""><blockquote type="cite" class=""><div class="">On Jun 30, 2016, at 9:45 PM, Daniel Berlin <<a href="mailto:dberlin@dberlin.org" class="">dberlin@dberlin.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Thu, Jun 30, 2016 at 6:09 PM, Carlos Liam via llvm-dev<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Hi all,<br class=""><br class="">Consider this C code:<br class=""><br class="">#include <stdbool.h><br class=""><br class="">bool func(int n1, int n2, bool b) {<br class="">   <span class="Apple-converted-space"> </span>bool greater = n1 > n2;<br class="">   <span class="Apple-converted-space"> </span>if (greater && b) {<br class="">       <span class="Apple-converted-space"> </span>if (n1 == n2) {<br class="">           <span class="Apple-converted-space"> </span>return false; // unreachable<br class="">       <span class="Apple-converted-space"> </span>}<br class="">   <span class="Apple-converted-space"> </span>}<br class="">   <span class="Apple-converted-space"> </span>return true;<br class="">}<br class=""><br class="">The line marked unreachable cannot be reached, however currently LLVM does not optimize it out</blockquote><div class="">?????<br class="">Yes it does.</div><div class=""><div class="">[dannyb@dannyb-macbookpro3 18:39:18] ~/sources/llvm (git-svn)-[newgvn-predicates]- :( $ clang -c -emit-llvm ~/greater.c -O1</div><div class="">[dannyb@dannyb-macbookpro3 18:39:22] ~/sources/llvm (git-svn)-[newgvn-predicates]- :) $ debug-build/bin/llvm-dis greater.bc</div><div class="">[dannyb@dannyb-macbookpro3 18:39:24] ~/sources/llvm (git-svn)-[newgvn-predicates]- :) $ cat greater.ll</div></div><div class="">; Function Attrs: norecurse nounwind readnone ssp uwtable</div><div class="">define zeroext i1 @func(i32, i32, i1 zeroext) #0 {</div><div class="">  ret i1 true</div><div class="">} </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">opt -simplifycfg -instcombine does the same thing to it if you use -O0 with clang </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"> </blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">I believe this is because LLVM does not recognize that meeting path conditions like, for example, X && Y logically means that X is true and Y is true.<br class=""></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Yes it does. See both GVN's propagateequality and correlatedvaluepropagation, among other things :)</div><div class=""><br class=""></div><div class="">In this case, simplifycfg +instcombine will do it</div><div class=""><br class=""></div><div class="">The new predicate support i'm building for GVN will also do it.</div><div class=""> <br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><br class="">I'm interested in creating a patch to remedy this; is there a file or function I should look at?<br class=""><br class="">Thanks in advance.<br class=""><br class=""> - CL<br class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></blockquote></div></div></blockquote></div><br class=""></body></html>