1  /* { dg-do compile } */
       2  /* { dg-options "-O3 -mavx2 -fdump-tree-fre5" } */
       3  
       4  void __attribute__((noinline,noclone))
       5  foo (int *out, int *res)
       6  {
       7    int mask[] = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
       8    int i;
       9    for (i = 0; i < 16; ++i)
      10      {
      11        if (mask[i])
      12          out[i] = i;
      13      }
      14    int o0 = out[0];
      15    int o7 = out[7];
      16    int o14 = out[14];
      17    int o15 = out[15];
      18    res[0] = o0;
      19    res[2] = o7;
      20    res[4] = o14;
      21    res[6] = o15;
      22  }
      23  
      24  /* Vectorization produces .MASK_STORE, unrolling will unroll the two
      25     vector iterations.  FRE5 after that should be able to CSE
      26     out[7] and out[15], but leave out[0] and out[14] alone.  */
      27  /* { dg-final { scan-tree-dump " = o0_\[0-9\]+;" "fre5" } } */
      28  /* { dg-final { scan-tree-dump " = 7;" "fre5" } } */
      29  /* { dg-final { scan-tree-dump " = o14_\[0-9\]+;" "fre5" } } */
      30  /* { dg-final { scan-tree-dump " = 15;" "fre5" } } */