[PATCH] Add new indexed load/store intrinsics.
ahmed.bougacha at gmail.com
Wed Apr 22 11:45:56 PDT 2015
In http://reviews.llvm.org/D9194#160053, @rengolin wrote:
> In http://reviews.llvm.org/D9194#159975, @HaoLiu wrote:
> > If the name of indexed.load indexed.store are not reasonable, how about indexed.gather and indexed.scatter like Elena used in http://reviews.llvm.org/D7665?
> I was under the impression that you two would use the same intrinsics, even though the hardware implementation is different, the IR concept should be generic enough to allow scatter/gather, masked loads and indexed loads to be represented in a generic way. Please comment on Elena's patch if you think we should use her intrinsics, but with a more generic name.
Again, I agree, and now I think just straight reusing Elena's intrinsic is probably enough.
%i3 = ...
%indices = insertelement ..., i32 %i3, i32 3
<4 x double> @llvm.indexed.load.v4f64 (double* %base, <4 x i32> %indices, i32 <alignment>)
seems equivalent to:
%i3 = ...
%p3 = getelementptr double* %base, i32 %i3
%ptrs = insertelement ..., double* %p3, i32 3
<4 x double> @masked.gather.v4f64 (<4 x double*> %ptrs, i32 <alignment>, <4 x i1> <1, 1, 1, 1>, <4 x double> undef)
The only problem is that the GEPs might get combined with the base somehow. So, the SelectionDAGBuilder (where it's useful to have both MLOAD and ILOAD) will have to look at the pointers, determine they're all at some constant index apart, and use ILOAD instead of MLOAD.
More information about the llvm-commits