Bug ID: 91446
           Summary: Wrong cost for scalar_load/scalar_store of vector type
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot
          Reporter: at gmail dot com
  Target Milestone: ---
            Target: i386

[hjl@gnu-skx-1 skx-3]$ cat x.i
typedef struct
  unsigned long width, height;
  long x, y;
} info;

extern void bar (info *);

foo (unsigned long width, unsigned long height, long x, long y)
  info t;
  t.width = width;
  t.height = height;
  t.x = x;
  t.y = y;
  bar (&t);
[hjl@gnu-skx-1 skx-3]$ make x.s
-B/export/build/gnu/tools-build/gcc-tuning-debug/build-x86_64-linux/gcc/ -Ofast
-march=skylake-avx512 -S x.i
[hjl@gnu-skx-1 skx-3]$ cat x.s
        .file   "x.i"
        .p2align 4
        .globl  foo
        .type   foo, @function
        subq    $40, %rsp
        .cfi_def_cfa_offset 48
        movq    %rdi, (%rsp)
        movq    %rsp, %rdi
        movq    %rsi, 8(%rsp)
        movq    %rdx, 16(%rsp)
        movq    %rcx, 24(%rsp)
        call    bar
        addq    $40, %rsp
        .cfi_def_cfa_offset 8
        .size   foo, .-foo
        .ident  "GCC: (GNU) 10.0.0 20190812 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-skx-1 skx-3]$ 

The problem is

(gdb) f 0
#0  ix86_builtin_vectorization_cost (type_of_cost=scalar_store, 
    at /export/gnu/import/git/intel/gcc-tuning/gcc/config/i386/i386.c:21090
21090                                 : ix86_cost->int_store [2]) / 2;
(gdb) p mode
$7 = E_V2DImode

     case scalar_load:
        /* load/store costs are relative to register move which is 2. Recompute
           it to COSTS_N_INSNS so everything have same base.  */
        return COSTS_N_INSNS (fp ? ix86_cost->sse_load[0]
                              : ix86_cost->int_load [2]) / 2;

      case scalar_store:
        return COSTS_N_INSNS (fp ? ix86_cost->sse_store[0]
                              : ix86_cost->int_store [2]) / 2;

2 DImode stores/loads are needed to store/load V2DImode.

Reply via email to