[PATCH] D155876: [PowerPC] vector cost model add cost to extract i1

Roland Froese via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 08:17:46 PDT 2023


RolandF added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp:738
+      return 3 + MaskCost;
+    }
   }
----------------
shchenz wrote:
> I must miss something. I compile following cases:
> ```
> define i1 @ext_ext_or_reduction_v4i1(<4 x i1> %z) {
>   %z1 = extractelement <4 x i1> %z, i32 1
>   ret i1 %z1
> }
> ```
> 
> ```
> define i32 @ext_ext_or_reduction_v4i32(<4 x i32> %z) {
>   %z1 = extractelement <4 x i32> %z, i32 1
>   ret i32 %z1
> }
> ```
> 
> Seems llc generates exactly same instructions for them at both pwr9 and pwr8. So don't understand why here we need extra cost for i1 types, the i1 type must have some kinds of users?
You will see the extra overhead if you compile the provided test case.  But looking at your example, notice that the value produced has 64 or 32 live bits - there are garbage bits in the results.  The return performs no calculation, it just functions like a copy, but the user would still have to get rid of those bits.  The uses will be scalar code - if we try to charge those with the overhead we will make the scalar loop cost more too, plus scalar code will already have the masking code there.


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

https://reviews.llvm.org/D155876



More information about the llvm-commits mailing list