<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 9/12/19 5:06 AM, David Zarzycki via llvm-dev wrote:<br>
</div>
<blockquote type="cite" cite="mid:FEAA3553-9828-4A7C-90D4-F5A3EABB1777@znu.io">I think adding a builtin to force CMOV or similar instructions on other architectures is long overdue. It’s generally useful, even if one isn’t mitigating speculative execution.</blockquote>
<p><br>
</p>
<p>I believe that you can currently get this effect using __builtin_unpredictable in Clang. __builtin_unpredictable wasn't added for this purpose, and it's a hint not a forced behavior, but I believe that it causes the backend to prefer cmov to branches during
 lowering.</p>
<p> -Hal<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:FEAA3553-9828-4A7C-90D4-F5A3EABB1777@znu.io">
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Sep 12, 2019, at 12:30 PM, Daan Sprenkels via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="" moz-do-not-send="true">llvm-dev@lists.llvm.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class=""><span style="caret-color: rgb(0, 0, 0);
                font-family: Menlo-Regular; font-size: 11px; font-style:
                normal; font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">PS.
 Perhaps, would there be interest to add such a feature to LLVM?</span><br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">I
 found this repository on GitHub[2], adding a `__builtin_ct_choose`</span><br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">intrinsic
 to clang. But as far as I know, this has never been upstreamed.</span><br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">[1]:
 Chandler Carruth described this trick at CppCon15:</span><br style="caret-color:
                rgb(0, 0, 0); font-family: Menlo-Regular; font-size:
                11px; font-style: normal; font-variant-caps: normal;
                font-weight: normal; letter-spacing: normal; text-align:
                start; text-indent: 0px; text-transform: none;
                white-space: normal; word-spacing: 0px;
                -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class=""><</span><a href="https://youtu.be/nXaxk27zwlk?t=2472" style="font-family: Menlo-Regular; font-size: 11px;
                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-size-adjust: auto;
                -webkit-text-stroke-width: 0px;" class="" moz-do-not-send="true">https://youtu.be/nXaxk27zwlk?t=2472</a><span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">>.
 See it in practice:</span><br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class=""><</span><a href="https://godbolt.org/z/UMPeku" style="font-family:
                Menlo-Regular; font-size: 11px; 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-size-adjust: auto;
                -webkit-text-stroke-width: 0px;" class="" moz-do-not-send="true">https://godbolt.org/z/UMPeku</a><span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">></span><br style="caret-color:
                rgb(0, 0, 0); font-family: Menlo-Regular; font-size:
                11px; font-style: normal; font-variant-caps: normal;
                font-weight: normal; letter-spacing: normal; text-align:
                start; text-indent: 0px; text-transform: none;
                white-space: normal; word-spacing: 0px;
                -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">[2]:
 <</span><a href="https://github.com/lmrs2/ct_choose" style="font-family: Menlo-Regular; font-size: 11px;
                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-size-adjust: auto;
                -webkit-text-stroke-width: 0px;" class="" moz-do-not-send="true">https://github.com/lmrs2/ct_choose</a><span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">>,</span><br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class=""><</span><a href="https://github.com/lmrs2/llvm/commit/8f9a4d952100ae03d06f10aee237bf8b3331da89" style="font-family: Menlo-Regular; font-size: 11px;
                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-size-adjust: auto;
                -webkit-text-stroke-width: 0px;" class="" moz-do-not-send="true">https://github.com/lmrs2/llvm/commit/8f9a4d952100ae03d06f10aee237bf8b3331da89</a><span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">>.</span><br style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none;" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
                Menlo-Regular; font-size: 11px; font-style: normal;
                font-variant-caps: normal; font-weight: normal;
                letter-spacing: normal; text-align: start; text-indent:
                0px; text-transform: none; white-space: normal;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                text-decoration: none; float: none; display: inline
                !important;" class="">Later
 published at S&P18.</span></div>
</blockquote>
</div>
<br class="">
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>