[PATCH] D148123: [AArch64][CostModel] Make sext/zext free if folded into a masked load

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 10:16:08 PDT 2023


dmgreen added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:2131
+      (CCH == TTI::CastContextHint::Masked) && ST->hasSVEorSME())
+    CCH = TTI::CastContextHint::Normal;
+
----------------
Is this always true that they are equivalent?

For a `nxv8i16 load zext to nxv8i32` (without masking) you can convert it into a pair of extending load (each cost 1, so load+zext costs 2 total).

The same can't be done for `nxv8i16 masked_load zext to nxv8i32` without either converting the nxv8i1 mask to two nxv4i1 masks, or zext a single load with a pair of uunpk's. (For MVE both are expensive so we give the instruction a high cost, preferring lower vector factors).


================
Comment at: llvm/test/Analysis/CostModel/AArch64/masked_ldst.ll:138
 
   %load.nxv8i8 = call <vscale x 8 x i8> @llvm.masked.load.nxv8i8.p0(ptr undef, i32 8, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
   %zext.nxv8i8to16 = zext <vscale x 8 x i8> %load.nxv8i8 to <vscale x 8 x i16>
----------------
If I'm reading this correctly, there are tests here for loading smaller types and extending them to legal types, but none for loading legal types and extending them. They might be worth adding.


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

https://reviews.llvm.org/D148123



More information about the llvm-commits mailing list