public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/43616] New: Extra register move
@ 2010-04-01 7:25 carrot at google dot com
2010-04-07 8:40 ` [Bug rtl-optimization/43616] [4.5, trunk] " ramana at gcc dot gnu dot org
2010-04-07 14:58 ` [Bug rtl-optimization/43616] " rguenth at gcc dot gnu dot org
0 siblings, 2 replies; 5+ messages in thread
From: carrot at google dot com @ 2010-04-01 7:25 UTC (permalink / raw)
To: gcc-bugs
Compile the following code with options -Os -march=armv7-a -mthumb
extern long long foo();
void bar2(long long* p)
{
long long t = foo();
*p = t;
}
GCC generates:
bar2:
push {r4, lr}
mov r4, r0
bl foo
mov r2, r0 // A
mov r3, r1 // B
strd r2, [r4] // C
pop {r4, pc}
1. The register moves in instructions AB is a regression relate to gcc4.4.0.
The result of gcc4.4 is:
push {r4, lr}
mov r4, r0
bl foo
strd r0, [r4]
pop {r4, pc}
The regression may be caused by some changes in ira. Before ira both versions
have similar rtx sequence:
(call_insn 6 3 7 2 src/tb.c:4 (parallel [
(set (reg:DI 0 r0)
(call (mem:SI (symbol_ref:SI ("foo") [flags 0x41]
<function_decl 0x7f623ba6a600 foo>) [0 S4 A32])
(const_int 0 [0x0])))
(use (const_int 0 [0x0]))
(clobber (reg:SI 14 lr))
]) 255 {*call_value_insn} (nil)
(nil))
(insn 7 6 8 2 src/tb.c:4 (set (reg/v:DI 133 [ t ])
(reg:DI 0 r0)) 657 {*thumb2_movdi} (nil))
(insn 8 7 0 2 src/tb.c:5 (set (mem:DI (reg/v/f:SI 134 [ p ]) [2 S8 A64])
(reg/v:DI 133 [ t ])) 657 {*thumb2_movdi} (expr_list:REG_DEAD
(reg/v/f:SI 134 [ p ])
(expr_list:REG_DEAD (reg/v:DI 133 [ t ])
(nil))))
After ira, gcc4.5 generates:
(call_insn 6 3 7 2 src/tb.c:4 (parallel [
(set (reg:DI 0 r0)
(call (mem:SI (symbol_ref:SI ("foo") [flags 0x41]
<function_decl 0x7f623ba6a600 foo>) [0 S4 A32])
(const_int 0 [0x0])))
(use (const_int 0 [0x0]))
(clobber (reg:SI 14 lr))
]) 255 {*call_value_insn} (nil)
(nil))
(insn 7 6 8 2 src/tb.c:4 (set (reg/v:DI 2 r2 [orig:133 t ] [133])
(reg:DI 0 r0)) 657 {*thumb2_movdi} (expr_list:REG_EQUIV (mem:DI
(reg/v/f:SI 4 r4 [orig:134 p ] [134]) [2 S8 A64])
(nil)))
(insn 8 7 11 2 src/tb.c:5 (set (mem:DI (reg/v/f:SI 4 r4 [orig:134 p ] [134]) [2
S8 A64])
(reg/v:DI 2 r2 [orig:133 t ] [133])) 657 {*thumb2_movdi} (nil))
But gcc4.4 generates:
(call_insn 6 3 8 2 src/tb.c:4 (parallel [
(set (reg:DI 0 r0)
(call (mem:SI (symbol_ref:SI ("foo") [flags 0x41]
<function_decl 0xf7d1c880 foo>) [0 S4 A32])
(const_int 0 [0x0])))
(use (const_int 0 [0x0]))
(clobber (reg:SI 14 lr))
]) 257 {*call_value_insn} (nil)
(nil))
(insn 8 6 16 2 src/tb.c:5 (set (mem:DI (reg/v/f:SI 4 r4 [orig:134 p ] [134]) [2
S8 A64])
(reg/v:DI 0 r0 [orig:133 t ] [133])) 651 {*thumb2_movdi} (nil))
2. Since r4 is never used again after instruction C, it can also be written as
a stm instruction. In thumb2, strd is a 32bit instruction, but stm is 16 bit.
--
Summary: Extra register move
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: carrot at google dot com
GCC build triplet: i686-linux
GCC host triplet: i686-linux
GCC target triplet: arm-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43616
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <bug-43616-4@http.gcc.gnu.org/bugzilla/>]
* [Bug rtl-optimization/43616] Extra register move
[not found] <bug-43616-4@http.gcc.gnu.org/bugzilla/>
@ 2012-06-17 11:04 ` ubizjak at gmail dot com
2023-05-16 23:39 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 5+ messages in thread
From: ubizjak at gmail dot com @ 2012-06-17 11:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43616
Uros Bizjak <ubizjak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|arm-eabi |arm-eabi, x86
Known to fail| |
--- Comment #2 from Uros Bizjak <ubizjak at gmail dot com> 2012-06-17 11:03:47 UTC ---
The same problem happens on x86_64:
--cut here--
void foo (void);
float test (float a, float b)
{
foo ();
return b;
}
--cut here--
gcc -O2
test:
.LFB0:
subq $24, %rsp
movss %xmm1, (%rsp)
call foo
A movss (%rsp), %xmm1
addq $24, %rsp
B movaps %xmm1, %xmm0
ret
We could move from stack directly to xmm0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug rtl-optimization/43616] Extra register move
[not found] <bug-43616-4@http.gcc.gnu.org/bugzilla/>
2012-06-17 11:04 ` ubizjak at gmail dot com
@ 2023-05-16 23:39 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-16 23:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43616
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |5.0
Status|NEW |RESOLVED
Resolution|--- |FIXED
Known to work| |5.1.0, 9.1.0
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The arm code generation was fixed in GCC 5 for the testcase in comment #0.
The x86_64 code generation was fixed in GCC 9 for the testcase in comment #2.
So fixed a long time ago for both.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-16 23:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-01 7:25 [Bug regression/43616] New: Extra register move carrot at google dot com
2010-04-07 8:40 ` [Bug rtl-optimization/43616] [4.5, trunk] " ramana at gcc dot gnu dot org
2010-04-07 14:58 ` [Bug rtl-optimization/43616] " rguenth at gcc dot gnu dot org
[not found] <bug-43616-4@http.gcc.gnu.org/bugzilla/>
2012-06-17 11:04 ` ubizjak at gmail dot com
2023-05-16 23:39 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).