On Wed, Sep 12, 2012 at 3:26 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 class="im"><br>
<br>
> -----Original Message-----<br>
> From: Eli Friedman [mailto:<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>]<br>
> Sent: Wednesday, September 12, 2012 3:22 PM<br>
> To: Villmow, Micah<br>
</div><div><div class="h5">> Cc: Richard Smith; <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>; <a href="mailto:llvmdev@cs.uiuc.edu">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">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?<br>
</div></div>[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.</blockquote>
<div><br></div><div>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.</div>
</div>