[PATCH] SelectionDAG: fold (fp_to_u/sint (u/sint_to_fp val)) when possible

Fiona Glaser fglaser at apple.com
Wed Feb 11 07:52:30 PST 2015


Um, this sounds very wrong.

The mantissa width is all about whether the float conversion causes rounding error, not about whether the value fits in the destination type. gcc doesn’t optimize out (int)(float)(int) for example, because that’s not legal.

Fiona

> On Feb 10, 2015, at 9:11 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:
> 
> The discussion ended up with: fptoui(), fptosi(), sitofp(), and uitofp() are all undefined if the value cannot fit in the destination type.
> 
> So I’d expect we go for the simple solution where we don’t care about getFPMantissaWidth().
> We only check getScalarSizeInBits() to insert the appropriate trunc or s/zext if necessary.
> 
> I assume that ISD::FP_TO_SINT (same with the other) has the same semantic as the IR instruction, and thus is applies to the DAG as well.
> 
>> Mehdi
> 
> 
> 
>> On Feb 10, 2015, at 6:35 PM, Fiona Glaser <fglaser at apple.com <mailto:fglaser at apple.com>> wrote:
>> 
>> Any comments on the rest of this?
>> 
>> Fiona
>> 
>>> On Feb 9, 2015, at 4:35 PM, Eric Christopher <echristo at gmail.com <mailto:echristo at gmail.com>> wrote:
>>> 
>>> Feel free to commit the change to port a test to FileCheck separately (and any time you'd like).
>>> 
>>> Thanks!
>>> 
>>> -eric
>>> 
>>> On Mon Feb 09 2015 at 2:53:45 PM Fiona Glaser <fglaser at apple.com <mailto:fglaser at apple.com>> wrote:
>>> Ah, sorry, missed the comments about the tests. Updated the DAG patch with edited and improved test and minor code fixes.
>>> 
>>> Fiona
>>> 
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150211/f0fa775f/attachment.html>


More information about the llvm-commits mailing list