<div dir="ltr">Ok, thank you for the clarification.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-07-25 14:29 GMT+02:00 Bruce Hoult <span dir="ltr"><<a href="mailto:bruce@hoult.org" target="_blank">bruce@hoult.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This seems like a misunderstanding of the standard.<div><br></div><div>For unsigned a, a << b is equal to (a * pow(2,b)) % (MAXUINT+1), *except* if b is greater than or equal to the word size, in which case the result is undefined.</div><div><br></div><div>For the particular case of 1 << 33, many machines will give 0 and many will give 2. Some many give other values. As far as the C standard, the result is undefined and llvm is correct. </div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Jul 25, 2017 at 3:15 PM, Anastasiya Ruzhanskaya via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div>I have also tested and found out, that however in this example:<br>  unsigned a = 1;<br>  unsigned b = a << 33;<br>  for (int i = 0; i < 32; i++)<br>    printf("%d ", ((b >> i) & 1));<br>  return b;<br></div><div> I get the undef value at the end:<br></div> <b> ret i32 undef</b><br></div>he bits are printed correctly - shifted by the modulo, as is defined in the standard. What is the explanation? <br></div>
<br></div></div>______________________________<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>
<br></blockquote></div><br></div>
</blockquote></div><br></div>