[PATCH] D75525: [TTI][ARM][MVE] Refine gather/scatter cost model

Anna Welker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 03:44:00 PDT 2020


anwel added inline comments.


================
Comment at: llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp:910
+            cast<Instruction>(Us)->getType()->getScalarSizeInBits();
+        if ((TypeSize == 32 && (EltSize == 8 || EltSize == 16)) ||
+            (TypeSize == 16 && EltSize == 8)) {
----------------
samparker wrote:
> Could we just return the ScalarCost if this isn't true?
Not always. A v8i16 gather that for some reason is extended to v8i32 would be checked here, too, and fail - although it's perfectly fine to build that gather 


================
Comment at: llvm/test/Analysis/CostModel/ARM/mve-gather-scatter-cost.ll:187-197
+  ; result zext
+  %gep5 = getelementptr i16, i16* %base16, <4 x i16> %ind16
+  %gep5.2 = getelementptr i32, i32* %base, <4 x i32> %ind32
+  %res5 = call <4 x i16> @llvm.masked.gather.v4i16.v4p0i16(<4 x i16*> %gep5, i32 2, <4 x i1> %mask, <4 x i16> undef)
+  %res5zext = zext <4 x i16> %res5 to <4 x i32>
+  call void @llvm.masked.scatter.v4i32.v4p0i32(<4 x i32> %res5zext, <4 x i32*> %gep5.2, i32 4, <4 x i1> %mask)
+  
----------------
dmgreen wrote:
> Can you move these into gep_v4i16. And add a trunc to the scatters. Maybe something like:
>   %res6 = call <4 x i16> @llvm.masked.gather.v4i16.v4p0i16(<4 x i16*> %gep5, i32 2, <4 x i1> %mask, <4 x i16> undef)
>   %res6sext = sext <4 x i16> %res6 to <4 x i32>
>   %res6trunc = trunc <4 x i32> %res6sext to <4 x i16>
>   call void @llvm.masked.scatter.v4i32.v4p0i32(<4 x i16> %res6trunc, <4 x i32*> %gep5.2, i32 4, <4 x i1> %mask)
> 
> If I haven't got that wrong, those scatters should be cheap(ish). It's probably worth adding similar v4i8 and v8i8 tests in too.
Have been moved. I moved those for v8i8, too, and created a set for v4i8.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75525/new/

https://reviews.llvm.org/D75525





More information about the llvm-commits mailing list