https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104059
Bug ID: 104059
Summary: cprop_hardreg propgates hard registers for mov
instructions between different REG_CLASS without
considering cost
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: crazylht at gmail dot com
Target Milestone: ---
int test (uint8_t *p, uint32_t t[1][1], int n) {
int sum = 0;
uint32_t a0;
for (int i = 0; i < 4; i++, p++)
t[i][0] = p[0];
for (int i = 0; i < 4; i++) {
{
int t0 = t[0][i] + t[0][i];
a0 = t0;
};
sum += a0;
}
return (((uint16_t)sum) + ((uint32_t)sum >> 16)) >> 1;
}
testcase is from PR104049, for x86 with -O3 -mavx2 ,before cprop_hardregs it's
----before cprop_hardreg------
(insn 100 79 81 2 (set (reg:SI 1 dx [orig:90 stmp__9.14 ] [90])
(reg:SI 20 xmm0 [114])) 81 {*movsi_internal}
(expr_list:REG_DEAD (reg:SI 20 xmm0 [114])
(nil)))
(debug_insn 81 100 96 2 (debug_marker) "/app/example.cpp":16:3 -1
(nil))
(insn 96 81 82 2 (set (reg:SI 0 ax [116])
(reg:SI 1 dx [orig:90 stmp__9.14 ] [90])) "/app/example.cpp":16:44 81
{*movsi_internal}
(nil))
---end------------
------after cprop_hardreg--------
(insn 100 79 81 2 (set (reg:SI 1 dx [orig:90 stmp__9.14 ] [90])
(reg:SI 20 xmm0 [114])) 81 {*movsi_internal}
(nil))
(debug_insn 81 100 96 2 (debug_marker) "/app/example.cpp":16:3 -1
(nil))
(insn 96 81 82 2 (set (reg:SI 0 ax [116])
(reg:SI 20 xmm0 [orig:90 stmp__9.14 ] [90])) "/app/example.cpp":16:44
81 {*movsi_internal}
(expr_list:REG_DEAD (reg:SI 20 xmm0 [orig:90 stmp__9.14 ] [90])
(nil)))
------end--------------
it's
vmovd edx, xmm0
movl eax, edx
vs
vmovd edx, xmm0
vmovd eax, xmm0
vmovd is expensive for many x86 targets.