public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3
@ 2010-08-16 6:25 adam at consulting dot net dot nz
2010-08-16 9:45 ` [Bug rtl-optimization/45296] " ubizjak at gmail dot com
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: adam at consulting dot net dot nz @ 2010-08-16 6:25 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]
#include <stdint.h>
register long double F80 __asm__("st");
typedef void (*inst_t)(uint32_t *ip);
void exec_inst(uint32_t *ip) {
((inst_t) (uint64_t) ip[0])(ip);
}
int main() {
return 0;
}
At -O2 and above gcc generates:
register_long_double_ICE.c:3:1: warning: call-clobbered register used for
global register variable
register_long_double_ICE.c: In function exec_inst:
register_long_double_ICE.c:9:1: internal compiler error: in compensate_edge, at
reg-stack.c:2789
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.5/README.Bugs> for instructions.
--
Summary: register long double ICE at -O2, -Os, -O3
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: adam at consulting dot net dot nz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
@ 2010-08-16 9:45 ` ubizjak at gmail dot com
2010-08-16 10:33 ` [Bug target/45296] " rguenth at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2010-08-16 9:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ubizjak at gmail dot com 2010-08-16 09:45 -------
(In reply to comment #0)
> At -O2 and above gcc generates:
>
> register_long_double_ICE.c:3:1: warning: call-clobbered register used for
> global register variable
Patient: Doctor, it hurts when I do this.
Doctor: Then stop doing it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
2010-08-16 9:45 ` [Bug rtl-optimization/45296] " ubizjak at gmail dot com
@ 2010-08-16 10:33 ` rguenth at gcc dot gnu dot org
2010-08-16 23:41 ` adam at consulting dot net dot nz
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-16 10:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2010-08-16 10:32 -------
we should reject st here.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|rtl-optimization |target
Keywords| |accepts-invalid, ice-on-
| |invalid-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
2010-08-16 9:45 ` [Bug rtl-optimization/45296] " ubizjak at gmail dot com
2010-08-16 10:33 ` [Bug target/45296] " rguenth at gcc dot gnu dot org
@ 2010-08-16 23:41 ` adam at consulting dot net dot nz
2010-08-17 6:12 ` jakub at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: adam at consulting dot net dot nz @ 2010-08-16 23:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from adam at consulting dot net dot nz 2010-08-16 23:41 -------
Why is this invalid gnu99 code?
How does one reserve x87 stack values as global register variables so that one
may use gnu99 operators such as + upon those global register variables instead
of having to resort to inline assembly?
Any function that does not contain an x87 operation should definitely compile.
Any function with x87 operations that do not push additional stack values
should definitely compile.
Rejecting st means rejects the top of the x87 stack as a global register
variable since st has a dual meaning [Unlike st(1), st(0) is an invalid
register name].
You should look at why GCC cannot satisfy compiler constraints for a function
that does not contain any x87 operations rather than throwing out the
possibility of x87 global register variables.
Here's another example of valid gnu99 code:
register long double F80a __asm__("st");
register long double F80b __asm__("st(1)");
void x87_add() {
F80a += F80b;
}
int main() {
return 0;
}
This does not ICE at -O3. How does one construct this code if you reject st?
Uros Bizjak: It is safe to designate a call-clobbered register as a global
register variable so long as the variable is saved when calling (implicit or
explicit) library functions ("The register will not be allocated for any other
purpose in the functions in the current compilation.")
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (2 preceding siblings ...)
2010-08-16 23:41 ` adam at consulting dot net dot nz
@ 2010-08-17 6:12 ` jakub at gcc dot gnu dot org
2010-08-17 6:58 ` ubizjak at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-08-17 6:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jakub at gcc dot gnu dot org 2010-08-17 06:12 -------
The GCC manual says that the register should be call-saved, that isn't the case
in your testcase, so it isn't valid.
But, more importantly, the i387 floating point stack is even more special, as
the st* registers change meaning during compilation - before reg-stack pass
they are just flat 8 registers and the reg-stack pass changes them into real
stacked registers, adding various fixup instructions. So, what is "st(1)"
before reg-stack can be at various depths in the i387 stack during the
function.
There is really no way to make this work. You can use inline-asm with "t"
resp. "u" constraints, but that's the only way you can directly influence the
operation of the i387 register stack.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (3 preceding siblings ...)
2010-08-17 6:12 ` jakub at gcc dot gnu dot org
@ 2010-08-17 6:58 ` ubizjak at gmail dot com
2010-08-17 9:38 ` ubizjak at gmail dot com
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2010-08-17 6:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from ubizjak at gmail dot com 2010-08-17 06:57 -------
(In reply to comment #3)
> Here's another example of valid gnu99 code:
>
> register long double F80a __asm__("st");
> register long double F80b __asm__("st(1)");
>
> void x87_add() {
> F80a += F80b;
> }
>
> int main() {
> return 0;
> }
>
> This does not ICE at -O3. How does one construct this code if you reject st?
The code does not do what you think should be doing:
x87_add:
.LFB0:
.cfi_startproc
flds .LC0(%rip)
flds .LC0(%rip)
faddp %st, %st(1)
flds .LC0(%rip)
fstp %st(0)
fstp %st(0)
ret
I'm testing following patch:
Index: reginfo.c
===================================================================
--- reginfo.c (revision 163291)
+++ reginfo.c (working copy)
@@ -798,6 +798,14 @@ fix_register (const char *name, int fixe
void
globalize_reg (int i)
{
+#ifdef STACK_REGS
+ if (IN_RANGE (i, FIRST_STACK_REG, LAST_STACK_REG))
+ {
+ error ("stack register used for global register variable");
+ return;
+ }
+#endif
+
if (fixed_regs[i] == 0 && no_global_reg_vars)
error ("global register variable follows a function definition");
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (4 preceding siblings ...)
2010-08-17 6:58 ` ubizjak at gmail dot com
@ 2010-08-17 9:38 ` ubizjak at gmail dot com
2010-08-17 12:25 ` uros at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2010-08-17 9:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from ubizjak at gmail dot com 2010-08-17 09:38 -------
Patch at http://gcc.gnu.org/ml/gcc-patches/2010-08/msg01226.html .
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |ubizjak at gmail dot com
|dot org |
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2010-
| |08/msg01226.html
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-08-17 09:38:43
date| |
Target Milestone|--- |4.4.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (5 preceding siblings ...)
2010-08-17 9:38 ` ubizjak at gmail dot com
@ 2010-08-17 12:25 ` uros at gcc dot gnu dot org
2010-08-17 14:22 ` uros at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu dot org @ 2010-08-17 12:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from uros at gcc dot gnu dot org 2010-08-17 12:25 -------
Subject: Bug 45296
Author: uros
Date: Tue Aug 17 12:25:24 2010
New Revision: 163303
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163303
Log:
PR target/45296
* reginfo.c (globalize_reg): Reject stack registers.
testsuite/ChangeLog:
PR target/45296
* gcc.target/i386/pr45296.c: New test.
Added:
trunk/gcc/testsuite/gcc.target/i386/pr45296.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/reginfo.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (6 preceding siblings ...)
2010-08-17 12:25 ` uros at gcc dot gnu dot org
@ 2010-08-17 14:22 ` uros at gcc dot gnu dot org
2010-08-17 14:26 ` uros at gcc dot gnu dot org
2010-08-17 14:27 ` ubizjak at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu dot org @ 2010-08-17 14:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from uros at gcc dot gnu dot org 2010-08-17 14:22 -------
Subject: Bug 45296
Author: uros
Date: Tue Aug 17 14:22:16 2010
New Revision: 163306
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163306
Log:
PR target/45296
* reginfo.c (globalize_reg): Reject stack registers.
testsuite/ChangeLog:
PR target/45296
* gcc.target/i386/pr45296.c: New test.
Added:
branches/gcc-4_5-branch/gcc/testsuite/gcc.target/i386/pr45296.c
- copied unchanged from r163303,
trunk/gcc/testsuite/gcc.target/i386/pr45296.c
Modified:
branches/gcc-4_5-branch/gcc/ChangeLog
branches/gcc-4_5-branch/gcc/reginfo.c
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (7 preceding siblings ...)
2010-08-17 14:22 ` uros at gcc dot gnu dot org
@ 2010-08-17 14:26 ` uros at gcc dot gnu dot org
2010-08-17 14:27 ` ubizjak at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: uros at gcc dot gnu dot org @ 2010-08-17 14:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from uros at gcc dot gnu dot org 2010-08-17 14:26 -------
Subject: Bug 45296
Author: uros
Date: Tue Aug 17 14:25:52 2010
New Revision: 163307
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163307
Log:
PR target/45296
* reginfo.c (globalize_reg): Reject stack registers.
testsuite/ChangeLog:
PR target/45296
* gcc.target/i386/pr45296.c: New test.
Added:
branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr45296.c
- copied unchanged from r163303,
trunk/gcc/testsuite/gcc.target/i386/pr45296.c
Modified:
branches/gcc-4_4-branch/gcc/ChangeLog
branches/gcc-4_4-branch/gcc/reginfo.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/45296] register long double ICE at -O2, -Os, -O3
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
` (8 preceding siblings ...)
2010-08-17 14:26 ` uros at gcc dot gnu dot org
@ 2010-08-17 14:27 ` ubizjak at gmail dot com
9 siblings, 0 replies; 11+ messages in thread
From: ubizjak at gmail dot com @ 2010-08-17 14:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from ubizjak at gmail dot com 2010-08-17 14:27 -------
Fixed.
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|4.4.6 |4.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45296
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-08-17 14:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-16 6:25 [Bug rtl-optimization/45296] New: register long double ICE at -O2, -Os, -O3 adam at consulting dot net dot nz
2010-08-16 9:45 ` [Bug rtl-optimization/45296] " ubizjak at gmail dot com
2010-08-16 10:33 ` [Bug target/45296] " rguenth at gcc dot gnu dot org
2010-08-16 23:41 ` adam at consulting dot net dot nz
2010-08-17 6:12 ` jakub at gcc dot gnu dot org
2010-08-17 6:58 ` ubizjak at gmail dot com
2010-08-17 9:38 ` ubizjak at gmail dot com
2010-08-17 12:25 ` uros at gcc dot gnu dot org
2010-08-17 14:22 ` uros at gcc dot gnu dot org
2010-08-17 14:26 ` uros at gcc dot gnu dot org
2010-08-17 14:27 ` ubizjak at gmail dot com
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).