public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/44025] Multiple load 0 to register
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-25 20:03 ` jakub at gcc dot gnu.org
2011-04-28 16:42 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-25 20:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44025
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.6.0 |4.6.1
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-25 19:53:06 UTC ---
GCC 4.6.0 is being released, adjusting target milestone.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug rtl-optimization/44025] Multiple load 0 to register
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
2011-03-25 20:03 ` [Bug rtl-optimization/44025] Multiple load 0 to register jakub at gcc dot gnu.org
@ 2011-04-28 16:42 ` rguenth at gcc dot gnu.org
2011-11-02 6:04 ` amker.cheng at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-28 16:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44025
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.6.1 |---
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug rtl-optimization/44025] Multiple load 0 to register
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
2011-03-25 20:03 ` [Bug rtl-optimization/44025] Multiple load 0 to register jakub at gcc dot gnu.org
2011-04-28 16:42 ` rguenth at gcc dot gnu.org
@ 2011-11-02 6:04 ` amker.cheng at gmail dot com
2011-11-02 6:05 ` amker.cheng at gmail dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: amker.cheng at gmail dot com @ 2011-11-02 6:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44025
--- Comment #4 from amker.cheng <amker.cheng at gmail dot com> 2011-11-02 06:03:56 UTC ---
I noticed that for attached reduced test case "reduced_test.c",
cse pass can eliminate such redundant load constant instructions.
But since cse works on extended basic block, rather than globally,
it can do nothing for the original case.
The questions are:
1, why pre does not do such optimization;
2, if pre does do the work, surely the live range of r0 is extended, which
might harm the register allocation;
Also I found the regcprop.c, which is a peephole pass eliminates redundant
register moves. It should be able to work for redundant constant load insns if
:
a) extend it in a value numbering way, at least for these constant values;
b) extend it in a global data analysis way;
Such change might also impact the scheduling pass and I am not sure how is the
benefit for common codes.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug rtl-optimization/44025] Multiple load 0 to register
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-11-02 6:04 ` amker.cheng at gmail dot com
@ 2011-11-02 6:05 ` amker.cheng at gmail dot com
2012-07-24 15:52 ` steven at gcc dot gnu.org
2012-07-24 18:17 ` steven at gcc dot gnu.org
5 siblings, 0 replies; 8+ messages in thread
From: amker.cheng at gmail dot com @ 2011-11-02 6:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44025
--- Comment #5 from amker.cheng <amker.cheng at gmail dot com> 2011-11-02 06:05:23 UTC ---
Created attachment 25687
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25687
reduced test case which can be handled by cse pass
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug rtl-optimization/44025] Multiple load 0 to register
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2011-11-02 6:05 ` amker.cheng at gmail dot com
@ 2012-07-24 15:52 ` steven at gcc dot gnu.org
2012-07-24 18:17 ` steven at gcc dot gnu.org
5 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu.org @ 2012-07-24 15:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44025
--- Comment #6 from Steven Bosscher <steven at gcc dot gnu.org> 2012-07-24 15:51:39 UTC ---
(In reply to comment #4)
> The questions are:
> 1, why pre does not do such optimization;
Because PRE (gcse.c) doesn't run at -Os.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug rtl-optimization/44025] Multiple load 0 to register
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2012-07-24 15:52 ` steven at gcc dot gnu.org
@ 2012-07-24 18:17 ` steven at gcc dot gnu.org
5 siblings, 0 replies; 8+ messages in thread
From: steven at gcc dot gnu.org @ 2012-07-24 18:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44025
--- Comment #7 from Steven Bosscher <steven at gcc dot gnu.org> 2012-07-24 18:16:17 UTC ---
Prototype patch attached to this email:
http://gcc.gnu.org/ml/gcc/2012-07/msg00189.html
It's not a finished patch, but it should be a good starting point for anyone
who really wants to fix this problem:
bar4:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
mov r3, r0
ldr r0, [r0, #520]
push {r4, r5, r6, lr}
mov r2, r3
mov r1, r3
adds r0, r3, r0
movs r6, #0
b .L9
.L4:
ldrb r5, [r2], #1 @ zero_extendqisi2
cmp r5, #10
bne .L9
mov r1, r2
movs r4, #0
strb r6, [r2, #-1]
.L9:
subs r5, r0, r2
cmp r5, #0
bgt .L4
cmp r1, r3
bne .L5
strb r4, [r1, #512]
pop {r4, r5, r6, pc}
.L10:
subs r4, r1, r3
mov r0, r3
mov r2, r4
bl memmove
mov r3, r0
.L11:
str r4, [r3, #520]
pop {r4, r5, r6, pc}
.L5:
ldr r2, [r3, #520]
adds r2, r3, r2
cmp r1, r2
bcs .L11
b .L10
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug rtl-optimization/44025] New: Multiple load 0 to register
@ 2010-05-07 13:19 carrot at google dot com
2010-05-07 13:20 ` [Bug rtl-optimization/44025] " carrot at google dot com
2010-09-01 10:34 ` ramana at gcc dot gnu dot org
0 siblings, 2 replies; 8+ messages in thread
From: carrot at google dot com @ 2010-05-07 13:19 UTC (permalink / raw)
To: gcc-bugs
Compile the attached source code with options -Os -march=armv7-a -mthumb, gcc
generates:
bar4:
push {r3, r4, r5, lr}
ldr r2, [r0, #520]
mov r4, r0
mov r3, r0
mov r1, r0
movs r0, #0 // A
b .L2
.L4:
ldrb r5, [r3], #1 @ zero_extendqisi2
cmp r5, #10
itt eq
moveq r1, r3
strbeq r0, [r3, #-1]
subs r2, r2, #1
.L2:
cmp r2, #0
bgt .L4
cmp r1, r4
bne .L8
movs r3, #0 //B
strb r3, [r1, #512] //C
b .L1
.L8:
ldr r3, [r4, #520]
adds r3, r4, r3
cmp r1, r3
bcc .L7
movs r3, #0 //D
str r3, [r4, #520] //E
b .L1
.L7:
subs r5, r1, r4
mov r0, r4
mov r2, r5
bl memmove
str r5, [r4, #520]
.L1:
pop {r3, r4, r5, pc}
Instructions B load constant 0 into register r3, and instruction C store 0 into
memory. Actually instruction A has already loaded 0 into register r0, and at
instruction C it is still available, so we can use r0 directly in instruction C
and remove B. Register r2 also contains 0 at instruction C, but it is more
difficult to detect. R0 can also be used at instruction E and remove D.
When compile with -O2 the result is similar.
Should this be handled by any cse pass and rematerialize it if there is high
register pressure?
--
Summary: Multiple load 0 to register
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
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=44025
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-07-24 18:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-44025-4@http.gcc.gnu.org/bugzilla/>
2011-03-25 20:03 ` [Bug rtl-optimization/44025] Multiple load 0 to register jakub at gcc dot gnu.org
2011-04-28 16:42 ` rguenth at gcc dot gnu.org
2011-11-02 6:04 ` amker.cheng at gmail dot com
2011-11-02 6:05 ` amker.cheng at gmail dot com
2012-07-24 15:52 ` steven at gcc dot gnu.org
2012-07-24 18:17 ` steven at gcc dot gnu.org
2010-05-07 13:19 [Bug rtl-optimization/44025] New: " carrot at google dot com
2010-05-07 13:20 ` [Bug rtl-optimization/44025] " carrot at google dot com
2010-09-01 10:34 ` ramana at gcc dot gnu dot 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).