On Wed, Sep 12, 2012 at 3:40 PM, Villmow, Micah <span dir="ltr"><<a href="mailto:Micah.Villmow@amd.com" target="_blank">Micah.Villmow@amd.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a> [mailto:<a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a>]
<b>On Behalf Of </b>Richard Smith<br>
<b>Sent:</b> Wednesday, September 12, 2012 3:30 PM<br>
<b>To:</b> Villmow, Micah<br>
<b>Cc:</b> Eli Friedman; <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>; <a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a></span></p><div><div class="h5"><br>
<b>Subject:</b> Re: [cfe-dev] [LLVMdev] SPIR Portability Discussion<u></u><u></u></div></div><p></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">On Wed, Sep 12, 2012 at 3:26 PM, Villmow, Micah <<a href="mailto:Micah.Villmow@amd.com" target="_blank">Micah.Villmow@amd.com</a>> wrote:<u></u><u></u></p>
</div></div><div><div><div class="h5">
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal"><br>
<br>
> -----Original Message-----<br>
> From: Eli Friedman [mailto:<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>]<br>
> Sent: Wednesday, September 12, 2012 3:22 PM<br>
> To: Villmow, Micah<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">> Cc: Richard Smith; <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>;
<a href="mailto:llvmdev@cs.uiuc.edu" target="_blank">llvmdev@cs.uiuc.edu</a><br>
> Subject: Re: [cfe-dev] [LLVMdev] SPIR Portability Discussion<br>
><br>
> On Wed, Sep 12, 2012 at 2:58 PM, Villmow, Micah <<a href="mailto:Micah.Villmow@amd.com" target="_blank">Micah.Villmow@amd.com</a>><br>
> wrote:<br>
> > Another factor to consider, with size_t etc as defined in SPIR, is<br>
> the usual<br>
> > arithmetic conversions. For instance (assuming a 64-bit long long),<br>
> > sizeof(int) + 1LL would be signed if size_t is 32 bits wide, and<br>
> would be<br>
> > unsigned if size_t is 64 bits wide. How is this handled?<br>
> ><br>
> > [Villmow, Micah] OpenCL C defines 'int' to be 32bits irrespective of<br>
> the<br>
> > host/device bitness. So this would follow the normal integer<br>
> promotion<br>
> > rules.<br>
><br>
> I think you're misunderstanding the issue: the point is, is<br>
> "sizeof(int) + -8LL < 0" true or false?<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal">[Villmow, Micah] Yep, I don't see why this is any different than "4 + -8LL < 0".  OpenCL C, and in turn SPIR, defines sizeof(int) == 4. While this might be a problem in C, this isn't an issue in OpenCL since there is no variance in the
 sizeof(int) across devices.<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div><div><div><div class="h5">
<p class="MsoNormal">I think you're still misunderstanding. If size_t is 32 bits, sizeof(int) + -8LL is -4LL, so the comparison produces true. If it's 64 bits, the -8LL promotes to an unsigned long long, sizeof(int) + -8LL is 18446744073709551612ULL, the 0
 promotes to 0ULL, and the comparison produces false.<u></u><u></u></p>
</div></div><p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">[Villmow, Micah] I see now, I think you had a type-o in the previous email, “sizeof(sizeof(int))” should have been size_t(sizeof(int)), which was throwing
 me off.</span></i></b></p></div></div></div></div></div></blockquote><div><br></div><div>What I wrote was what I meant. The *value* of sizeof(int) is not relevant here, what matters is the precision of its type (or more specifically, its integer conversion rank).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div><div><p class="MsoNormal"><b><i><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Though I’m curious where it states we have to promote -8LL to unsigned long and not signed long, I would have thought it would be signed.\</span></i></b></p>
</div></div></div></div></div></blockquote><div><br></div><div>C99 <a href="http://6.3.1.8/1">6.3.1.8/1</a>.</div></div>