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

--- Comment #2 from Vineet Gupta <vineet.gupta at linux dot dev> ---
I've experimented with riscv_rtx_costs() setting cost of const to 1 as
discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98596. This does
reduce the number of li 4096 instances to 10 (from 14), but the fragment pasted
above generates the same code.

# rhs-cred.cc:42: (*(double *)((char *)&ao)[k] + *(double *)((char *)0)[12] +
#(insn 2660 1703 76 (set (reg:DI 28 t3 [2817])
#        (const_int 4096 [0x1000])) "rhs-cred.cc":42:47 139 {*movdi_64bit}
#     (nil))
        li      t3,4096         # tmp2817,      # 2660  [c=1 l=4] 
*movdi_64bit/1


# rhs-cred.cc:39: bg = (&ao[az])[0] * *(&ao)[av] + *(&ao)[2];
#(insn 76 2660 2661 (set (reg/f:DI 16 a6 [orig:193 _239 ] [193])
#        (plus:DI (reg:DI 12 a2 [1860])
#            (reg:DI 16 a6 [orig:181 _224 ] [181]))) "rhs-cred.cc":39:40 4
{adddi3}
#     (expr_list:REG_DEAD (reg:DI 12 a2 [1860])
#        (nil)))
        add     a6,a2,a6        # _224, _239, tmp1860   # 76    [c=4 l=4] 
adddi3/0


# rhs-cred.cc:42: (*(double *)((char *)&ao)[k] + *(double *)((char *)0)[12] +
#(insn 2661 76 2658 (set (reg:DI 12 a2 [2816])
#        (plus:DI (reg:DI 28 t3 [2817])
#            (const_int -2040 [0xfffffffffffff808]))) "rhs-cred.cc":42:47 4
{adddi3}
#     (expr_list:REG_DEAD (reg:DI 28 t3 [2817])
#        (expr_list:REG_EQUAL (const_int 2056 [0x808])
#            (nil))))
        addi    a2,t3,-2040     #, tmp2816, tmp2817     # 2661  [c=4 l=4] 
adddi3/1

# rhs-cred.cc:44: *(&ao)[av * 2] - *(&ao)[k] - (&ao[az])[2] +
#(insn 2658 2661 1702 (set (reg:DI 28 t3 [2815])
#        (const_int 4096 [0x1000])) "rhs-cred.cc":44:29 139 {*movdi_64bit}
#     (nil))

        li      t3,4096         # tmp2815,      # 2658  [c=1 l=4] 
*movdi_64bit/1

Reply via email to