Hi Guys, I am trying to promote half to float for my intrinsic math operations, following class and pattern are defined. " class S_HF__HF< string asmstr> : Intrinsic <[llvm_float_ty ], [llvm_float_ty ], [IntrNoMem], !strconcat(asmstr, "_f16")>; def :Pat<( f16 (int_my_math_f16 f16:$src)), (F2Hsr (FEXTsr f16:$src) )>; “ where FEXTsr is implementing the fextend type profile, F2Hsr is implementing as the float to half conversion . “int_my_math_f16” is implementing the “S_HF__HF” profile above. I am just trying to (1) convert the $src from f16 to f32 using FEXTsr. (2) use the F2Hsr to convert the f32 back to f16. for testing. however, I always got the error ” Type inference contradiction found, merging 'f32' into 'f16' def :Pat<( f16 (int_my_math_f16 f16:$src)), (F_2_F16sr (FEXTsr f16:$src) )>; “ Wondering what is the reason? I noticed that LLVM does not have the intrinsic type “LLVM_f16_ty”, so I always use “LLVM_float_ty” for it as long as it is a float or half. best Kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150212/7024df3d/attachment.html>
On Thu, Feb 12, 2015 at 8:48 AM, kewuzhang <kewu.zhang at amd.com> wrote:> > Hi Guys, > > I am trying to promote half to float for my intrinsic math operations, > following class and pattern are defined. > > " > class S_HF__HF< string asmstr> : Intrinsic > <[llvm_float_ty ], [llvm_float_ty ], > [IntrNoMem], > !strconcat(asmstr, "_f16")>; > > def :Pat<( f16 (int_my_math_f16 f16:$src)), (F2Hsr (FEXTsr f16:$src) )>; > > > “ > where FEXTsr is implementing the fextend type profile, F2Hsr is > implementing as the float to half conversion . > “int_my_math_f16” is implementing the “S_HF__HF” profile above. > I am just trying to > (1) convert the $src from f16 to f32 using FEXTsr. > (2) use the F2Hsr to convert the f32 back to f16. > for testing. > however, I always got the error > ” > Type inference contradiction found, merging 'f32' into 'f16' > def :Pat<( f16 (int_my_math_f16 f16:$src)), (F_2_F16sr (FEXTsr f16:$src) )>; > > “ > > > Wondering what is the reason? I noticed that LLVM does not have the > intrinsic type “LLVM_f16_ty”, so I always use “LLVM_float_ty” for it as long > as it is a float or half.Hi Kevin, In "llvm_float_ty", "float" means f32 (as in the IR language reference, and as defined in include/llvm/IR/Intrinsics.td). So in your example, TableGen complains because you're feeding an f16 to an intrinsic declared as taking an f32. However, there's also "llvm_half_ty" in Intrinsics.td, corresponding to f16; why not use that instead? -Ahmed> best > > Kevin > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Thank you very much! don’t know why I just overlooked the llvm_half_ty when I was reading the intrinsics.td best kevin On Feb 12, 2015, at 1:31 PM, Ahmed Bougacha <ahmed.bougacha at gmail.com> wrote:> On Thu, Feb 12, 2015 at 8:48 AM, kewuzhang <kewu.zhang at amd.com> wrote: >> >> Hi Guys, >> >> I am trying to promote half to float for my intrinsic math operations, >> following class and pattern are defined. >> >> " >> class S_HF__HF< string asmstr> : Intrinsic >> <[llvm_float_ty ], [llvm_float_ty ], >> [IntrNoMem], >> !strconcat(asmstr, "_f16")>; >> >> def :Pat<( f16 (int_my_math_f16 f16:$src)), (F2Hsr (FEXTsr f16:$src) )>; >> >> >> “ >> where FEXTsr is implementing the fextend type profile, F2Hsr is >> implementing as the float to half conversion . >> “int_my_math_f16” is implementing the “S_HF__HF” profile above. >> I am just trying to >> (1) convert the $src from f16 to f32 using FEXTsr. >> (2) use the F2Hsr to convert the f32 back to f16. >> for testing. >> however, I always got the error >> ” >> Type inference contradiction found, merging 'f32' into 'f16' >> def :Pat<( f16 (int_my_math_f16 f16:$src)), (F_2_F16sr (FEXTsr f16:$src) )>; >> >> “ >> >> >> Wondering what is the reason? I noticed that LLVM does not have the >> intrinsic type “LLVM_f16_ty”, so I always use “LLVM_float_ty” for it as long >> as it is a float or half. > > Hi Kevin, > > In "llvm_float_ty", "float" means f32 (as in the IR language > reference, and as defined in include/llvm/IR/Intrinsics.td). So in > your example, TableGen complains because you're feeding an f16 to an > intrinsic declared as taking an f32. > > However, there's also "llvm_half_ty" in Intrinsics.td, corresponding > to f16; why not use that instead? > > -Ahmed > >> best >> >> Kevin >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150212/4e7242eb/attachment.html>
On Thu, Feb 12, 2015 at 11:48:17AM -0500, kewuzhang wrote:> > Hi Guys, > > I am trying to promote half to float for my intrinsic math operations, > following class and pattern are defined. > > " > class S_HF__HF< string asmstr> : Intrinsic > <[llvm_float_ty ], [llvm_float_ty ], > [IntrNoMem], > !strconcat(asmstr, "_f16")>; > > def :Pat<( f16 (int_my_math_f16 f16:$src)), (F2Hsr (FEXTsr f16:$src) )>; > > > “ > where FEXTsr is implementing the fextend type profile, F2Hsr is implementing as the float to half conversion . > “int_my_math_f16” is implementing the “S_HF__HF” profile above. > I am just trying to > (1) convert the $src from f16 to f32 using FEXTsr. > (2) use the F2Hsr to convert the f32 back to f16. > for testing. > however, I always got the error > ” > Type inference contradiction found, merging 'f32' into 'f16' > def :Pat<( f16 (int_my_math_f16 f16:$src)), (F_2_F16sr (FEXTsr f16:$src) )>; > > “ > > > Wondering what is the reason? I noticed that LLVM does not have the intrinsic type “LLVM_f16_ty”, so I always use “LLVM_float_ty” for it as long as it is a float or half. >There is llvm_half_ty. Try defining your intrinsic with that instead of llvm_float_ty. -Tom> best > > Kevin> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev