<div dir="ltr">On Mon, Jan 7, 2019 at 5:50 AM Clement Courbet <<a href="mailto:courbet@google.com">courbet@google.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi David & James,</div><div><br></div><div class="gmail_quote"><div dir="ltr">On Sat, Jan 5, 2019 at 1:17 AM David Jones <<a href="mailto:david.jones@metrics.ca" target="_blank">david.jones@metrics.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">If we are considering an optimization to convert calls to memcmp into bcmp, then does it make sense to add an intrinsic for bcmp like there is for memcmp?  That way IR writers can express their requirements precisely: memcmp if you care about the direction of inequality, and bcmp if you do not.</div></blockquote><div><br></div><div>As mentioned in my answer to Hal above, I think the backend at least should be able to do this.</div><div><br></div><div>Then adding an intrinsic is only for for convenience, because if the backend can do the optimization automatically it's enough for the frontend to emit the attribute. For example, for a language that has a runtime which as a memeq/bcmp, the frontend could just emit the call site annotation. I have no strong opinion on whether the convenience justifies an intrinsic.</div></div></div></blockquote><div>However, there may be cases where the optimizer cannot determine that a call to memcmp can be reduced to bcmp.  e.g. I pass the result of memcmp() to some externally-defined function unknown to LLVM. I would like to be able to specify bcmp explicitly in this case.</div><div><br></div><div> <br></div></div></div>