You are right, to use rndz is not just an optimization. We must use rndz here. Xionghu, please fix it.
Thanks. On Thu, Jan 15, 2015 at 08:24:29AM +0000, Song, Ruiling wrote: > Sorry, I previously thought it was for integer to integer truncation. > For the floating point llvm.trunc to nearest integer, you need use RNDZ. > When you convert from float to 32bit integer, numbers larger than 2^31 will > get wrong result. > Floating point value range is larger than integer. > > > -----Original Message----- > > From: Zhigang Gong [mailto:[email protected]] > > Sent: Thursday, January 15, 2015 4:13 PM > > To: Song, Ruiling; Luo, Xionghu; [email protected] > > Cc: Luo, Xionghu > > Subject: RE: [Beignet] [PATCH 3/3] add llvm intrinsic call translate. > > > > > > > > > -----Original Message----- > > > From: Beignet [mailto:[email protected]] On Behalf > > > Of Song, Ruiling > > > Sent: Thursday, January 15, 2015 4:00 PM > > > To: Luo, Xionghu; [email protected] > > > Cc: Luo, Xionghu > > > Subject: Re: [Beignet] [PATCH 3/3] add llvm intrinsic call translate. > > > > > > > + case Intrinsic::trunc: > > > > + { > > > > + Type *llvmDstType = I.getType(); > > > > + Type *llvmSrcType = I.getOperand(0)->getType(); > > > > + ir::Type dstType = getType(ctx, llvmDstType); > > > > + ir::Type srcType = getType(ctx, llvmSrcType); > > > > + GBE_ASSERT(srcType == dstType); > > > > + > > > > + const ir::Register tmp = ctx.reg(getFamily(ir::TYPE_S32)); > > > > + const ir::Register dst = this->getRegister(&I); > > > > + const ir::Register src = > > this->getRegister(I.getOperand(0)); > > > > + ctx.CVT(ir::TYPE_S32, srcType, tmp, src); > > > > + ctx.CVT(dstType, ir::TYPE_S32, dst, tmp); > > > Why do we need to convert to TYPE_S32 to convert from TYPE_S32 to > > dstType? > > This is what llvm.trunc's purpose: > > > > ‘llvm.trunc.*‘ Intrinsic > > > > Syntax: > > > > This is an overloaded intrinsic. You can use llvm.trunc on any floating > > point > > or vector of floating point type. Not all targets support all types however. > > > > declare float @llvm.trunc.f32(float %Val) > > declare double @llvm.trunc.f64(double %Val) > > declare x86_fp80 @llvm.trunc.f80(x86_fp80 %Val) > > declare fp128 @llvm.trunc.f128(fp128 %Val) > > declare ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %Val) > > Overview: > > > > The ‘llvm.trunc.*‘ intrinsics returns the operand rounded to the nearest > > integer not larger in magnitude than the operand. > > > > > > > > _______________________________________________ > > > Beignet mailing list > > > [email protected] > > > http://lists.freedesktop.org/mailman/listinfo/beignet > _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
