<div dir="ltr"><div><div>Resending to "everyone":<br></div><div><br>What's wrong with checking <br><br>short foo(double d)<br>{<br>    if (trunc(d) > MAX_SHORT || trunc(d) < MIN_SHORT) return 0; else return short(d);<br>}<br><br></div>If you don't care about the one in difference, you could do `abs(trunc(d)) < MAX_SHORT;` to avoid the check against min.<br><br></div><div>That's what you want, right?<br></div><div><br>--<br></div>Mats</div><div class="gmail_extra"><br><div class="gmail_quote">On 28 January 2016 at 11:17, Simon Byrne 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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank Tom and Tim for your responses.<br>
<br>
If the behaviour is truly undefined as Tom says, would it be possible<br>
to get checked intrinsics for this?<br>
<span class="HOEnZb"><font color="#888888"><br>
-Simon<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 22 January 2016 at 20:24, Tim Northover <<a href="mailto:t.p.northover@gmail.com">t.p.northover@gmail.com</a>> wrote:<br>
> On 22 January 2016 at 12:20, Tom Stellard via llvm-dev<br>
> <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>> 1) I realise this is a somewhat silly question, but is this still<br>
>>> acceptable "undefined behaviour"?<br>
>><br>
>> Yes, it is.<br>
><br>
> I always thought these out-of-range instructions did produce an<br>
> "undef" rather than allowing fully-general undefined behaviour<br>
> (otherwise we couldn't speculate them, for a start).<br>
><br>
> If so, I think the code ought to be valid: %1 is *some* i16<br>
> bitpattern, which means %2 cannot be completely unconstrained and<br>
> should never be equal to %0.<br>
><br>
> Cheers.<br>
><br>
> Tim.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">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/mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>