1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
http://bugs.gentoo.org/182374
http://gcc.gnu.org/PR32389
2007-06-21 Uros Bizjak <ubizjak@gmail.com>
PR target/32389
* config/i386/i386.h (enum ix86_stack_slot): Add SLOT_VIRTUAL.
* config/i386/i386.c (assign_386_stack_local): Assert that
SLOT_VIRTUAL is valid only before virtual regs are instantiated.
(ix86_expand_builtin) [IX86_BUILTIN_LDMXCSR, IX86_BUILTIN_STMXCSR]:
Use SLOT_VIRTUAL stack slot instead of SLOT_TEMP.
* config/i386/i386.md (truncdfsf2, truncxfsf2, truncxfdf2): Ditto.
---
gcc/config/i386/i386.c | 7 +++++--
gcc/config/i386/i386.h | 3 ++-
gcc/config/i386/i386.md | 6 +++---
gcc/testsuite/gcc.target/i386/pr32389.c | 10 ++++++++++
4 files changed, 20 insertions(+), 6 deletions(-)
Index: gcc-4.1.2/gcc/testsuite/gcc.target/i386/pr32389.c
===================================================================
--- /dev/null
+++ gcc-4.1.2/gcc/testsuite/gcc.target/i386/pr32389.c
@@ -0,0 +1,10 @@
+/* Testcase by Mike Frysinger <vapier@gentoo.org> */
+
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-msse" } */
+
+double f1();
+int f2() {
+ __builtin_ia32_stmxcsr();
+ return f1();
+}
Index: gcc-4.1.2/gcc/config/i386/i386.h
===================================================================
--- gcc-4.1.2.orig/gcc/config/i386/i386.h
+++ gcc-4.1.2/gcc/config/i386/i386.h
@@ -2206,7 +2206,8 @@ enum ix86_entity
enum ix86_stack_slot
{
- SLOT_TEMP = 0,
+ SLOT_VIRTUAL = 0,
+ SLOT_TEMP,
SLOT_CW_STORED,
SLOT_CW_TRUNC,
SLOT_CW_FLOOR,
Index: gcc-4.1.2/gcc/config/i386/i386.md
===================================================================
--- gcc-4.1.2.orig/gcc/config/i386/i386.md
+++ gcc-4.1.2/gcc/config/i386/i386.md
@@ -3684,7 +3684,7 @@
;
else
{
- rtx temp = assign_386_stack_local (SFmode, SLOT_TEMP);
+ rtx temp = assign_386_stack_local (SFmode, SLOT_VIRTUAL);
emit_insn (gen_truncdfsf2_with_temp (operands[0], operands[1], temp));
DONE;
}
@@ -3836,7 +3836,7 @@
DONE;
}
else
- operands[2] = assign_386_stack_local (SFmode, SLOT_TEMP);
+ operands[2] = assign_386_stack_local (SFmode, SLOT_VIRTUAL);
})
(define_insn "*truncxfsf2_mixed"
@@ -3934,7 +3934,7 @@
DONE;
}
else
- operands[2] = assign_386_stack_local (DFmode, SLOT_TEMP);
+ operands[2] = assign_386_stack_local (DFmode, SLOT_VIRTUAL);
})
(define_insn "*truncxfdf2_mixed"
Index: gcc-4.1.2/gcc/config/i386/i386.c
===================================================================
--- gcc-4.1.2.orig/gcc/config/i386/i386.c
+++ gcc-4.1.2/gcc/config/i386/i386.c
@@ -12865,6 +12865,9 @@ assign_386_stack_local (enum machine_mod
gcc_assert (n < MAX_386_STACK_LOCALS);
+ /* Virtual slot is valid only before vregs are instantiated. */
+ gcc_assert ((n == SLOT_VIRTUAL) == !virtuals_instantiated);
+
for (s = ix86_stack_locals; s; s = s->next)
if (s->mode == mode && s->n == n)
return s->rtl;
@@ -15496,13 +15499,13 @@ ix86_expand_builtin (tree exp, rtx targe
case IX86_BUILTIN_LDMXCSR:
op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
- target = assign_386_stack_local (SImode, SLOT_TEMP);
+ target = assign_386_stack_local (SImode, SLOT_VIRTUAL);
emit_move_insn (target, op0);
emit_insn (gen_sse_ldmxcsr (target));
return 0;
case IX86_BUILTIN_STMXCSR:
- target = assign_386_stack_local (SImode, SLOT_TEMP);
+ target = assign_386_stack_local (SImode, SLOT_VIRTUAL);
emit_insn (gen_sse_stmxcsr (target));
return copy_to_mode_reg (SImode, target);
|