Hi, Following is excerpted from http://llvm.org/releases/3.1/docs/LangRef.html#int_ctpop. How come the return type needs to be consistent with parameter type? i64/i128 seems to be overkill, and i8, i16 are inconvenient. ----------------------------------- declare i8 @llvm.ctpop.i8(i8 <src>) declare i16 @llvm.ctpop.i16(i16 <src>) declare i32 @llvm.ctpop.i32(i32 <src>) declare i64 @llvm.ctpop.i64(i64 <src>) declare i256 @llvm.ctpop.i256(i256 <src>) declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>) ----------------------------------------------- Thanks Shuxin
On Tue, Nov 13, 2012 at 4:53 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:> Hi, > > Following is excerpted from > http://llvm.org/releases/3.1/docs/LangRef.html#int_ctpop. > How come the return type needs to be consistent with parameter type? > i64/i128 seems to be overkill, > and i8, i16 are inconvenient. > > ----------------------------------- > declare i8 @llvm.ctpop.i8(i8 <src>) > declare i16 @llvm.ctpop.i16(i16 <src>) > declare i32 @llvm.ctpop.i32(i32 <src>) > declare i64 @llvm.ctpop.i64(i64 <src>) > declare i256 @llvm.ctpop.i256(i256 <src>) > declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>)It's basically just for the sake of simplicity... why should the intrinsic be overloaded over two types if only one is necessary? If there's a compelling use-case, it wouldn't be difficult to make the return type independent of the operand type, but I'm not sure why it matters. -Eli
On Nov 13, 2012, at 4:53 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:> Hi, > > Following is excerpted from http://llvm.org/releases/3.1/docs/LangRef.html#int_ctpop. > How come the return type needs to be consistent with parameter type? i64/i128 seems to be overkill, > and i8, i16 are inconvenient.It isn't required at the machine code level, it is just to make clients of the IR simpler, because ctpop (and other bithack intrinsics) are simpler that way. Also, picking any fixed result type won't work: you have to support vectors. Allowing it to be arbitrary just adds complexity. -Chris> > ----------------------------------- > declare i8 @llvm.ctpop.i8(i8 <src>) > declare i16 @llvm.ctpop.i16(i16 <src>) > declare i32 @llvm.ctpop.i32(i32 <src>) > declare i64 @llvm.ctpop.i64(i64 <src>) > declare i256 @llvm.ctpop.i256(i256 <src>) > declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>) > ----------------------------------------------- > > Thanks > Shuxin > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev