<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 26, 2015 at 10:29 AM, Pete Cooper <span dir="ltr"><<a href="mailto:peter_cooper@apple.com" target="_blank">peter_cooper@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="adM"><div class=""><blockquote type="cite"><div>On Jan 26, 2015, at 10:24 AM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 25, 2015 at 9:37 PM, Pete Cooper <span dir="ltr"><<a href="mailto:peter_cooper@apple.com" target="_blank">peter_cooper@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">Hi hfinkel,<br>
<br>
This teaches the constant folder that an llvm.expect intrinsic with a constant as the first operand will return that constant.<br>
<br>
This reduces the size of an LTO'd llc by over 1% due to branches which can be removed once the constant is propagated.</div></blockquote></div><br></div><div class="gmail_extra">I really don't understand this.</div><div class="gmail_extra"><br></div><div class="gmail_extra">The design llvm.expect was specifically for LowerExpect to remove *all* of these intrinsics from the IR? Why isn't that working?</div></div>
</div></blockquote></div></div>Looks like LowerExpect is only added in populateFunctionPassManager, which is only called by clang, opt, and bug point.  There’s no call to this in llvm-lto.</div><div><br></div><div>I still think its worthwhile to constant fold expect as soon as possible as this patch does, but it looks like we also need that pass in the LTO pipeline.</div></blockquote></div><br>I really don't think it is. We should be running LowerExpect really early in every single pass pipeline because, as you saw, there are tons of passes we would have to teach about it otherwise. Not constant folding is, if anything, a nice way to flush these issues out.</div></div>