[PATCH] D98243: [LV] Account for the cost of predication of scalarized load/store

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 9 02:44:54 PST 2021


dmgreen created this revision.
dmgreen added reviewers: RKSimon, SjoerdMeijer, fhahn, spatel, sdesmalen.
Herald added subscribers: pengfei, hiraditya, kristof.beyls.
dmgreen requested review of this revision.
Herald added a project: LLVM.

This adds the cost of an i1 extract and a branch to the cost in getMemInstScalarizationCost when the instruction is predicated. These predicated loads/store would generate blocks of something like:

    %c1 = extractelement <4 x i1> %C, i32 1
    br i1 %c1, label %if, label %else
  if:
    %sa = extractelement <4 x i32> %a, i32 1
    %sb = getelementptr inbounds float, float* %pg, i32 %sa
    %sv = extractelement <4 x float> %x, i32 1
    store float %sa, float* %sb, align 4
  else:

So this increases the cost by the extract and branch. This is probably still too low in many cases due to the cost of all that branching, but there is already an existing hack increasing the cost using useEmulatedMaskMemRefHack. It will increase the cost if it is a load or there are more than one store. This patch improves the cost for when there is only a single store improving the attached test.

(The hack can hopefully be removed at some point. I think it would be OK to remove from the ARM testing I tried, but there are a number of X86 tests that suggest it's still needed, and the cost of an i1 extract + branch is probably too low to accurately represent the cost of trying to perform all these branches).


https://reviews.llvm.org/D98243

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/ARM/mve-predstorecost.ll
  llvm/test/Transforms/LoopVectorize/X86/small-size.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98243.329247.patch
Type: text/x-patch
Size: 26216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210309/e900c89f/attachment.bin>


More information about the llvm-commits mailing list