llvm-project/llvm/test/Analysis/CostModel/AArch64
Adhemerval Zanella cadcfed7aa [AArch64] Add custom lowering for v4i8 trunc store
This patch adds a custom trunc store lowering for v4i8 vector types.
Since there is not v.4b register, the v4i8 is promoted to v4i16 (v.4h)
and default action for v4i8 is to extract each element and issue 4
byte stores.

A better strategy would be to extended the promoted v4i16 to v8i16
(with undef elements) and extract and store the word lane which
represents the v4i8 subvectores. The construction:

  define void @foo(<4 x i16> %x, i8* nocapture %p) {
    %0 = trunc <4 x i16> %x to <4 x i8>
    %1 = bitcast i8* %p to <4 x i8>*
    store <4 x i8> %0, <4 x i8>* %1, align 4, !tbaa !2
    ret void
  }

Can be optimized from:

  umov    w8, v0.h[3]
  umov    w9, v0.h[2]
  umov    w10, v0.h[1]
  umov    w11, v0.h[0]
  strb    w8, [x0, #3]
  strb    w9, [x0, #2]
  strb    w10, [x0, #1]
  strb    w11, [x0]
  ret

To:

  xtn     v0.8b, v0.8h
  str     s0, [x0]
  ret

The patch also adjust the memory cost for autovectorization, so the C
code:

  void foo (const int *src, int width, unsigned char *dst)
  {
    for (int i = 0; i < width; i++)
       *dst++ = *src++;
  }

can be vectorized to:

  .LBB0_4:                                // %vector.body
                                          // =>This Inner Loop Header: Depth=1
        ldr     q0, [x0], #16
        subs    x12, x12, #4            // =4
        xtn     v0.4h, v0.4s
        xtn     v0.8b, v0.8h
        st1     { v0.s }[0], [x2], #4
        b.ne    .LBB0_4

Instead of byte operations.

llvm-svn: 335735
2018-06-27 13:58:46 +00:00
..
bswap.ll
div.ll [AArch64] Adjust the cost of integer vector division 2018-03-07 22:35:32 +00:00
div_cte.ll [AArch64] Improve cost of vector division by constant 2018-05-09 12:48:22 +00:00
free-widening-casts.ll [AArch64] Consider widening instructions in cost calculations 2017-05-09 20:18:12 +00:00
gep.ll Revert r314923: "Recommit : Use the basic cost if a GEP is not used as addressing mode" 2017-10-13 14:04:21 +00:00
kryo.ll
lit.local.cfg
select.ll
shuffle-select.ll [CostModel][AArch64] Add some initial costs for SK_Select and SK_PermuteSingleSrc 2018-06-22 09:45:31 +00:00
shuffle-transpose.ll [TTI, AArch64] Add transpose shuffle kind 2018-04-26 13:48:33 +00:00
store.ll [AArch64] Add custom lowering for v4i8 trunc store 2018-06-27 13:58:46 +00:00
vector-reduce.ll [AArch64] Implement getArithmeticReductionCost 2018-03-16 11:34:15 +00:00