[PATCH] D50665: [LV][LAA] Vectorize loop invariant values stored into loop invariant address

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 13:45:31 PDT 2018


anna added a comment.

In https://reviews.llvm.org/D50665#1212899, @hsaito wrote:

> We should also consider doing this, depending on the cost of branch versus masked scatter. For the targets w/o masked scatter, this should be better than masked scatter emulation.
>
> %5 = bitcast <16xi1> %4 to <i16>
>  %6 = icmp eq <i16> %5, <i16> zero
>  br <i1> %6 skip fall
> fall:
>  store <i32> %ntrunc, <i32*> %a
>  br skip
> skip:


Yes, that is the improved codegen stated as TODO in the costmodel. Today both the costmodel and the code gen will identify it as a normal predicated store: series of branches and stores. Also, we need to differentiate these 2 cases:

  if(b[i] ==k)
   a = ntrunc;

versus

  if(b[i] ==k)
    a = ntrunc;
  else
    a = m;

The second example should be converted into a vector-select based on b[i] == k and the last element will be extracted out of the vector select and stored into a.
However, if for some reason, it is not converted into a select and just left as 2 predicated stores, it is incorrect to use the same code transformation as we'll do for the first example. For the first example, we see if all values in the conditional is false, and we skip the store. In the second case, we need to store a value, but that value is just decided by the last element of the conditional. Just 2 different forms of predicated stores.


Repository:
  rL LLVM

https://reviews.llvm.org/D50665





More information about the llvm-commits mailing list