https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127885

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
t.c:37:59: note: Cost model analysis for whole subgraph:
  Vector cost: 216
  Scalar cost: 208
t.c:37:59: missed: not vectorized: vectorization is not profitable.

We are now appropriately costing

t.c:37:59: note: op template: mask_18 = foo_ptr.0_1->explicit_mask[0];
t.c:37:59: note:        [l*]stmt 0 mask_18 = foo_ptr.0_1->explicit_mask[0];
t.c:37:59: note:        [l] stmt 1 mask_18 = foo_ptr.0_1->explicit_mask[0];
t.c:37:59: note:        [l] stmt 2 mask_18 = foo_ptr.0_1->explicit_mask[0];
t.c:37:59: note:        [l] stmt 3 mask_18 = foo_ptr.0_1->explicit_mask[0];
t.c:37:59: note:        load permutation { 0 0 0 0 }

as

foo_ptr.0_1->explicit_mask[0] 1 times vec_to_scalar costs 16 in body

and code generated as

  vect_mask_18.8_39 = MEM <vector(4) long unsigned int> [(long unsigned int
*)vectp.7_38];
  vect_mask_18.9_40 = VEC_PERM_EXPR <vect_mask_18.8_39, vect_mask_18.8_39, { 0,
0, 0, 0 }>;
  _41 = BIT_FIELD_REF <vect_mask_18.9_40, 64, 0>;
  _2 = (int) _41;
  x_param_align_loop_iterations = _2;

and

        vmovdqu (%rcx), %ymm2
        vpermq  $0, %ymm2, %ymm0
        vmovd   %xmm2, x_param_align_loop_iterations(%rip)

that's the missed anticipation of a store-use I noted in the patch submission.

But I costing shows this was only profitable by a very low margin, 204 vs 208.

Costing a single splat more appropriately or rather code-generating it as such

node 0x5866240 foo_ptr.0_1->explicit_mask[0] 1 times vec_perm costs 4 in body
node 0x5866240 foo_ptr.0_1->explicit_mask[0] 1 times unaligned_load (misalign
-1) costs 20 in body
node 0x5866240 foo_ptr.0_1->explicit_mask[0] 1 times vec_to_scalar costs 16 in
body

can recover that.  But all cost adjustments come with regressions.

Reply via email to