public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/47763] New: Useless initialization of register
@ 2011-02-16 7:08 jiez at gcc dot gnu.org
2011-02-16 7:43 ` [Bug rtl-optimization/47763] " jakub at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-16 7:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
Summary: Useless initialization of register
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jiez@gcc.gnu.org
For arm-eabi target and options "-O2 -funroll-loops", gcc compiles the
following empty function
foo()
{
}
to
foo:
mov r0, #0
bx lr
Apparently the first instruction is useless.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
@ 2011-02-16 7:43 ` jakub at gcc dot gnu.org
2011-02-16 7:48 ` jiez at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-02-16 7:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-02-16 07:35:09 UTC ---
The function is not empty, it is returning an uninitialized value as int. If
you want an empty function, use void foo () {}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
2011-02-16 7:43 ` [Bug rtl-optimization/47763] " jakub at gcc dot gnu.org
@ 2011-02-16 7:48 ` jiez at gcc dot gnu.org
2011-02-16 7:51 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-16 7:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #2 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-16 07:42:45 UTC ---
OK. From this point, it's not empty. But if it returns an uninitialized value,
why bother initialize r0 to 0.
Btw, the patch in reviewing:
http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00787.html
I just realized that we need a new PR number for the test case. So I reported
this bug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
2011-02-16 7:43 ` [Bug rtl-optimization/47763] " jakub at gcc dot gnu.org
2011-02-16 7:48 ` jiez at gcc dot gnu.org
@ 2011-02-16 7:51 ` jakub at gcc dot gnu.org
2011-02-16 8:08 ` jiez at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-02-16 7:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-02-16 07:48:24 UTC ---
Why should we care about code quality of function with undefined behavior?
Various optimizations add zero initialization or assume zero initialization of
undefined variables.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (2 preceding siblings ...)
2011-02-16 7:51 ` jakub at gcc dot gnu.org
@ 2011-02-16 8:08 ` jiez at gcc dot gnu.org
2011-02-16 8:20 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-16 8:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #4 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-16 07:59:19 UTC ---
Yeah, normally we don't care about such cases. But this one comes from
dhrystone. If it can be fixed cleanly, why not do it?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (3 preceding siblings ...)
2011-02-16 8:08 ` jiez at gcc dot gnu.org
@ 2011-02-16 8:20 ` pinskia at gcc dot gnu.org
2011-02-16 8:36 ` jiez at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-02-16 8:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-02-16 08:08:33 UTC ---
(In reply to comment #4)
> Yeah, normally we don't care about such cases. But this one comes from
> dhrystone. If it can be fixed cleanly, why not do it?
Then the whole dhrystone benchmark is invalid and should not be trusted. I
think people should report the bug to the benchmark maker and then declare all
previous results of the benchmark as invalid. In fact any benchmark which
depends on undefined code should not be trusted.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (4 preceding siblings ...)
2011-02-16 8:20 ` pinskia at gcc dot gnu.org
@ 2011-02-16 8:36 ` jiez at gcc dot gnu.org
2011-02-16 8:55 ` jiez at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-16 8:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #6 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-16 08:32:14 UTC ---
I think we all know that dhrystone is a bad benchmark. But some users don't.
Which is more difficult: educating all users about that vs apply a simple patch
in GCC to remove the useless initialization? 4.4 does has such initialization.
But 4.5 has. Fixing this is an improvement and does not hurt. From another
point, leaving it unfixed does not help GCC.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (5 preceding siblings ...)
2011-02-16 8:36 ` jiez at gcc dot gnu.org
@ 2011-02-16 8:55 ` jiez at gcc dot gnu.org
2011-02-16 11:21 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-16 8:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #7 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-16 08:49:46 UTC ---
Sorry, in my last comment, I meant to say "4.4 does NOT have such
initialization".
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (6 preceding siblings ...)
2011-02-16 8:55 ` jiez at gcc dot gnu.org
@ 2011-02-16 11:21 ` rguenth at gcc dot gnu.org
2011-02-16 11:51 ` jiez at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-16 11:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.02.16 11:04:15
Ever Confirmed|0 |1
--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-16 11:04:15 UTC ---
The difference is that with -funroll-loops the init_regs pass isn't presented
with
(insn 8 7 6 2 (clobber (reg:SI 59 [ <retval> ])) t.c:1 -1
(nil))
and thus inserts a zero-initialization instruction. I wonder whether
it could instead insert a clobber.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (7 preceding siblings ...)
2011-02-16 11:21 ` rguenth at gcc dot gnu.org
@ 2011-02-16 11:51 ` jiez at gcc dot gnu.org
2011-02-16 18:31 ` schwab@linux-m68k.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-16 11:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #9 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-16 11:29:50 UTC ---
The clobber is optimized away in 172r.cprop3 because the register renaming in
171r.web breaks the def-use relationship between the clobber and the use in the
following instruction when -funroll-loops is used. My patch prevents the
renaming in such case.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (8 preceding siblings ...)
2011-02-16 11:51 ` jiez at gcc dot gnu.org
@ 2011-02-16 18:31 ` schwab@linux-m68k.org
2011-02-23 0:37 ` jiez at gcc dot gnu.org
2011-02-23 0:38 ` jiez at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: schwab@linux-m68k.org @ 2011-02-16 18:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #10 from Andreas Schwab <schwab@linux-m68k.org> 2011-02-16 18:26:31 UTC ---
There is no undefined behaviour if all calls to foo ignore the returned value.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (9 preceding siblings ...)
2011-02-16 18:31 ` schwab@linux-m68k.org
@ 2011-02-23 0:37 ` jiez at gcc dot gnu.org
2011-02-23 0:38 ` jiez at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-23 0:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
--- Comment #11 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-23 00:25:38 UTC ---
Author: jiez
Date: Wed Feb 23 00:25:34 2011
New Revision: 170422
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170422
Log:
PR rtl-optimization/47763
* web.c (web_main): Ignore naked clobber when replacing register.
testsuite/
PR rtl-optimization/47763
* gcc.dg/pr47763.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/pr47763.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/web.c
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug rtl-optimization/47763] Useless initialization of register
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
` (10 preceding siblings ...)
2011-02-23 0:37 ` jiez at gcc dot gnu.org
@ 2011-02-23 0:38 ` jiez at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jiez at gcc dot gnu.org @ 2011-02-23 0:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47763
Jie Zhang <jiez at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.0
--- Comment #12 from Jie Zhang <jiez at gcc dot gnu.org> 2011-02-23 00:27:15 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-02-23 0:27 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 7:08 [Bug rtl-optimization/47763] New: Useless initialization of register jiez at gcc dot gnu.org
2011-02-16 7:43 ` [Bug rtl-optimization/47763] " jakub at gcc dot gnu.org
2011-02-16 7:48 ` jiez at gcc dot gnu.org
2011-02-16 7:51 ` jakub at gcc dot gnu.org
2011-02-16 8:08 ` jiez at gcc dot gnu.org
2011-02-16 8:20 ` pinskia at gcc dot gnu.org
2011-02-16 8:36 ` jiez at gcc dot gnu.org
2011-02-16 8:55 ` jiez at gcc dot gnu.org
2011-02-16 11:21 ` rguenth at gcc dot gnu.org
2011-02-16 11:51 ` jiez at gcc dot gnu.org
2011-02-16 18:31 ` schwab@linux-m68k.org
2011-02-23 0:37 ` jiez at gcc dot gnu.org
2011-02-23 0:38 ` jiez 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).