implement SIMD gather/scatter via vector getelementptr by RalfJung · Pull Reques...
source link: https://github.com/rust-lang/rust/pull/95961
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
let layout = bx.layout_of(pointee.ty);
let ptrs = args[0].immediate();
let offsets = args[1].immediate();
return Ok(bx.gep(bx.backend_type(layout), ptrs, &[offsets]));
Does gep
type check this? Or can calling the intrinsic improperly result in an LLVM codegen error?
I don't know, so we should probably add a codegen test rather than finding out the hard way. gep
isn't that complex but it's known to ambush unwary compiler engineers when they turn their back on it. I can help draft such a codegen test if necessary.
This does about as much checking as the arith_offset
intrinsic, I think. The one extra check there is that the offsets
must be ptr-sized integers, which arith_offset
enforces via the type signature (but I am not sure if anything checks that type signature). I can try to add that here.
What kind of codegen test are you looking for?
I added a check for the integer type in the second operand.
Oh, I mostly just want to see with this that we generate a vector of pointers to the given type and then gep it like we Damn Well Should and don't suddenly somehow revert to scalar operations or something like that. A smoke test that the suite of intrinsics used to do a gather or scatter compiles correctly, basically, and that the types don't go suddenly weird on us.
This does about as much checking as the arith_offset intrinsic, I think. The one extra check there is that the offsets must be ptr-sized integers, which arith_offset enforces via the type signature (but I am not sure if anything checks that type signature). I can try to add that here.
For the #[repr(simd)]
types, while we do type-checking in rustc's front and "middle" phases to guarantee the input vector types are valid machine vector types, you can assume that it probably has bypassed any sensible checking like "is this even actually a pointer?" and is relying heavily on correct usage. Thus we would like to error during monomorphization on anything fishy.
That is to say:
It is important to error in mono (as you do here) because I do not believe we have anything before this step that would even enforce that the first arg to simd_arith_offset
would be a vector of pointers.
Oh, I mostly just want to see with this that we generate a vector of pointers to the given type
Okay... I'll try my best but I barely ever work with codegen tests so I am not even sure of the syntax to use.^^ Is there another portable-simd codegen test I could model this off of?
Should it go through portable-simd APIs or call the intrinsics directly?
A smoke test that the suite of intrinsics used to do a gather or scatter compiles correctly, basically, and that the types don't go suddenly weird on us.
We have the doctests as smoke tests as well. ;)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK