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

--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
testcase:

#ifndef TYPE
#define TYPE vector double
#endif

struct foo {
  TYPE a, b, c, d;
};

/* Make sure we don't use direct moves to get stuff into GPR registers.  */
void
gpr (struct foo *p)
{
  TYPE x = p->c;

  __asm__ (" # reg = %0" : "+r" (x));

  p->b = x;
}


Here's dump in ira.

-------------
a2(r117,l0) costs: BASE_REGS:12000,12000 GENERAL_REGS:12000,12000
FLOAT_REGS:0,0 ALTIVEC_REGS:0,0 VSX_REGS:0,0 GEN_OR_FLOAT_REGS:12000,12000
GEN_OR_VSX_REGS:12000,12000 MEM:0,0
....
(insn 6 3 13 2 (set (reg/v:V2DF 117 [ x ])
        (mem:V2DF (plus:DI (reg/v/f:DI 118 [ p ])
                (const_int 32 [0x20])) [1 p_2(D)->c+0 S16 A128]))
"testsuite/gcc.target/powerpc/dform-3.c":23:8 1148 {vsx_movv2df_64bit}
     (nil))
(insn 13 6 8 2 (set (reg:V2DF 119 [ x ])
        (reg/v:V2DF 117 [ x ])) "testsuite/gcc.target/powerpc/dform-3.c":25:3
-1
     (nil))
(insn 8 13 9 2 (parallel [
            (set (reg:V2DF 119 [ x ])
                (asm_operands:V2DF (" # reg = %0") ("=r") 0 [
                        (reg:V2DF 119 [ x ])
                    ]
                     [
                        (asm_input:V2DF ("0")
testsuite/gcc.target/powerpc/dform-3.c:25)
                    ]
                     [] testsuite/gcc.target/powerpc/dform-3.c:25))
            (clobber (reg:SI 98 ca))
        ]) "testsuite/gcc.target/powerpc/dform-3.c":25:3 -1
---------------


And after my commit, RA take best scenario when preferred reg_class is unkown,
which make cost of MEM:0,0 of r117 same as VSX_REGS:0,0, and allocate r117 as
VSX_REGS, which create an extra move and failed the testcase.

Reply via email to