[llvm-dev] Strange types on x86 vcvtph2ps and vcvtps2ph intrinsics

Dan Liew via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 8 16:48:15 PDT 2015


Hi,

I was looking at the x86 vector intrinsics for converting half
precision floating point numbers and I'm a bit confused as to why
certain types were chosen. I've gone ahead and used their current
definition with success but I'd like to understand why the types used
with these intrinsics are done this way.

For reference see ``include/llvm/IR/IntrinsicsX86.td``. Here are the
intrinsics of interest.

```
let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
  def int_x86_vcvtph2ps_128 : GCCBuiltin<"__builtin_ia32_vcvtph2ps">,
              Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
  def int_x86_vcvtph2ps_256 : GCCBuiltin<"__builtin_ia32_vcvtph2ps256">,
              Intrinsic<[llvm_v8f32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
  def int_x86_vcvtps2ph_128 : GCCBuiltin<"__builtin_ia32_vcvtps2ph">,
              Intrinsic<[llvm_v8i16_ty], [llvm_v4f32_ty, llvm_i32_ty],
                        [IntrNoMem]>;
  def int_x86_vcvtps2ph_256 : GCCBuiltin<"__builtin_ia32_vcvtps2ph256">,
              Intrinsic<[llvm_v8i16_ty], [llvm_v8f32_ty, llvm_i32_ty],
                        [IntrNoMem]>;

```

Here's what seems weird to me:

* For the 4 wide intrinsics (``_128`` suffix) some of the types are
wider than they need to be. For example ``int_x86_vcvtph2ps_128``
takes <8 x i16> as an argument but this intrinsic only uses the first
four lanes so why is the argument type not <4 x i16>?
``int_x86_vcvtps2ph_128`` also has the same oddity but on its return
type (returns <8 x i16> but only the first four are relevant).

* The use of ``i16`` types also seems a little strange given that the
more semantically correct ``f16`` type and vectorized forms (e.g.
``llvm_v4f16_ty``) are available. Sure I can use a bitcast with the
intrinsics to get the type I want in the IR but why were ``i16`` was
chosen over using ``f16``?

Any ideas?

Thanks,
Dan.


More information about the llvm-dev mailing list