[PATCH] Avoid conversion to float when creating ConstantDataArray/ConstantDataVector

Raoux, Thomas F thomas.f.raoux at intel.com
Tue Feb 10 21:44:33 PST 2015


Hi Nick,

>Please give getFP its own group with its own doxygen comment describing the conversion, and maybe mention that float and double are defined in LangRef to be 32 and 64 bits respectively. It would >be nice if this also handled half, fp128, x86_fp80 and ppc_fp128, to be orthogonal.
I changed added comments for getFP and I added a constructor for half. I can't think of a good constructor signature for the other float types.

>Elts.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
>
>There's no actual zero-extension happening here, right? If not, I don't really see a clearly way to write it, maybe getLimitedValue?
I changed the getZExtValue() to getLimitedValue

The new patch is attached. Could someone commit it since I don't have write access?

Thomas

-----Original Message-----
From: Nick Lewycky [mailto:nicholas at mxc.ca] 
Sent: Sunday, February 08, 2015 2:40 PM
To: Raoux, Thomas F
Cc: 'llvm-commits at cs.uiuc.edu'
Subject: Re: [PATCH] Avoid conversion to float when creating ConstantDataArray/ConstantDataVector

Raoux, Thomas F wrote:
> Re-attaching the patch

+  static Constant *getFP(LLVMContext &Context, ArrayRef<uint32_t> 
+ Elts);  static Constant *getFP(LLVMContext &Context, 
+ ArrayRef<uint64_t> Elts);

Please give getFP its own group with its own doxygen comment describing the conversion, and maybe mention that float and double are defined in LangRef to be 32 and 64 bits respectively. It would be nice if this also handled half, fp128, x86_fp80 and ppc_fp128, to be orthogonal.

-            Elts.push_back(CFP->getValueAPF().convertToFloat());
+ 
Elts.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());

There's no actual zero-extension happening here, right? If not, I don't really see a clearly way to write it, maybe getLimitedValue?

The logic of the change and test look good to me.

Nick

>
> -----Original Message-----
> From: Raoux, Thomas F
> Sent: Thursday, February 05, 2015 10:23 AM
> To: 'llvm-commits at cs.uiuc.edu'
> Subject: [PATCH] Avoid conversion to float when creating 
> ConstantDataArray/ConstantDataVector
>
> Ping. Could someone look at this patch about ConstantDataVector?
>
> -----Original Message-----
> From: Raoux, Thomas F
> Sent: Wednesday, January 28, 2015 8:15 AM
> To: 'llvm-commits at cs.uiuc.edu'
> Subject: [Patch] Avoid conversion to float when creating 
> ConstantDataArray/ConstantDataVector
>
> Hi,
>
> Could someone review (and possibly commit) this patch related to ConstantDataArray/ConstantDataVector?
>
> This addresses a bug discussed in this thread: 
> http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-January/080575.html
>
> To avoid conversion to float and potential change of the constant I added new constructors for float types for ConstantDataArray/ConstantDataVector.
>
> Cheers,
> Thomas
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ConstantDataVector.patch
Type: application/octet-stream
Size: 10180 bytes
Desc: ConstantDataVector.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150211/e88c110c/attachment.obj>


More information about the llvm-commits mailing list