aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/gcc/gcc-4.3.3/ep93xx/arm-crunch-mieee.patch
blob: 793f52506d27f1a42602be46d7b5e7edad605536 (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
This patch adds an -mieee flag to GCC for ARM, that only has any effect when
hard MaverickCrunch FPU code generation is selected.
It disables the buggy instructions that do not recognise or do not generate
denormalized values when they should:
	add, sub, neg, abs and float<->double conversions.
That leaves only floating point multiplication, comparison, conversions to/from
integers and the 64-bit integer operations.

   Martin Guy <martinwguy@yahoo.it>, December 2008

--- gcc-4.3.2/gcc/doc/invoke.texi.old	2008-06-25 02:37:53.000000000 +0100
+++ gcc-4.3.2/gcc/doc/invoke.texi	2008-12-04 11:48:54.000000000 +0000
@@ -430,6 +430,7 @@
 -mpic-register=@var{reg} @gol
 -mnop-fun-dllimport @gol
 -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol
+-mieee @gol
 -mpoke-function-name @gol
 -mthumb  -marm @gol
 -mtpcs-frame  -mtpcs-leaf-frame @gol
@@ -8682,6 +8683,15 @@
 can be re-enabled by use of the @option{-mno-cirrus-fix-invalid-insns}
 switch.
 
+@item -mieee
+When compiling for the Maverick FPU, disable the instructions that fail
+to honor denormalized values. As these include floating point add, sub,
+neg, abs and float<->double conversions, it incurs a severe speed penalty.
+This option only has an effect if the
+@option{-mcpu=ep9312} @option{-mfpu=maverick} options have been used and is
+disabled by default.
+The default can be re-enabled by use of the @option{-mno-ieee} switch.
+
 @item -mpoke-function-name
 @opindex mpoke-function-name
 Write the name of each function into the text section, directly
--- gcc-4.3.2/gcc/config/arm/arm.opt.old	2007-08-02 11:49:31.000000000 +0100
+++ gcc-4.3.2/gcc/config/arm/arm.opt	2008-12-04 11:42:50.000000000 +0000
@@ -93,6 +93,10 @@
 Target RejectNegative
 Alias for -mfloat-abi=hard
 
+mieee
+Target Report Mask(IEEE)
+Cirrus: Enable denormalized values by disabling buggy Maverick instructions
+
 mlittle-endian
 Target Report RejectNegative InverseMask(BIG_END)
 Assume target CPU is configured as little endian
--- gcc-4.3.2/gcc/config/arm/arm.c.old	2008-11-21 19:09:18.000000000 +0000
+++ gcc-4.3.2/gcc/config/arm/arm.c	2008-12-03 12:03:31.000000000 +0000
@@ -902,6 +902,10 @@
       target_float_abi_name = "hard";
       return true;
 
+    case OPT_mieee:
+      target_flags |= MASK_IEEE;
+      return true;
+
     case OPT_msoft_float:
       target_float_abi_name = "soft";
       return true;
--- gcc-4.3.2/gcc/config/arm/arm.md.old	2008-12-03 15:29:38.000000000 +0000
+++ gcc-4.3.2/gcc/config/arm/arm.md	2008-12-04 12:14:56.000000000 +0000
@@ -831,7 +831,7 @@
   [(set (match_operand:SF          0 "s_register_operand" "")
 	(plus:SF (match_operand:SF 1 "s_register_operand" "")
 		 (match_operand:SF 2 "arm_float_add_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   "
   if (TARGET_MAVERICK
       && !cirrus_fp_register (operands[2], SFmode))
@@ -842,7 +842,7 @@
   [(set (match_operand:DF          0 "s_register_operand" "")
 	(plus:DF (match_operand:DF 1 "s_register_operand" "")
 		 (match_operand:DF 2 "arm_float_add_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   "
   if (TARGET_MAVERICK
       && !cirrus_fp_register (operands[2], DFmode))
@@ -1064,7 +1064,7 @@
   [(set (match_operand:SF           0 "s_register_operand" "")
 	(minus:SF (match_operand:SF 1 "arm_float_rhs_operand" "")
 		  (match_operand:SF 2 "arm_float_rhs_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   "
   if (TARGET_MAVERICK)
     {
@@ -1079,7 +1079,7 @@
   [(set (match_operand:DF           0 "s_register_operand" "")
 	(minus:DF (match_operand:DF 1 "arm_float_rhs_operand" "")
 		  (match_operand:DF 2 "arm_float_rhs_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   "
   if (TARGET_MAVERICK)
     {
@@ -3367,7 +3367,7 @@
 	(neg:SF (match_operand:SF 1 "s_register_operand" "")))]
   "TARGET_32BIT && TARGET_HARD_FLOAT
    && (TARGET_FPA || TARGET_VFP
-       || (TARGET_MAVERICK && ! HONOR_SIGNED_ZEROS(SFmode))"
+       || (TARGET_MAVERICK && ! HONOR_SIGNED_ZEROS(SFmode) && ! TARGET_IEEE))"
   ""
 )
 
@@ -3376,7 +3376,7 @@
 	(neg:DF (match_operand:DF 1 "s_register_operand" "")))]
   "TARGET_32BIT && TARGET_HARD_FLOAT
    && (TARGET_FPA || TARGET_VFP
-       || (TARGET_MAVERICK && ! HONOR_SIGNED_ZEROS(DFmode))"
+       || (TARGET_MAVERICK && ! HONOR_SIGNED_ZEROS(DFmode) && ! TARGET_IEEE))"
   "")
 
 ;; abssi2 doesn't really clobber the condition codes if a different register
@@ -3456,13 +3456,13 @@
 (define_expand "abssf2"
   [(set (match_operand:SF         0 "s_register_operand" "")
 	(abs:SF (match_operand:SF 1 "s_register_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   "")
 
 (define_expand "absdf2"
   [(set (match_operand:DF         0 "s_register_operand" "")
 	(abs:DF (match_operand:DF 1 "s_register_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   "")
 
 (define_expand "sqrtsf2"
@@ -3600,7 +3600,7 @@
   [(set (match_operand:SF  0 "s_register_operand" "")
 	(float_truncate:SF
  	 (match_operand:DF 1 "s_register_operand" "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   ""
 )
 
@@ -4462,7 +4462,7 @@
 (define_expand "extendsfdf2"
   [(set (match_operand:DF                  0 "s_register_operand" "")
 	(float_extend:DF (match_operand:SF 1 "s_register_operand"  "")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && !(TARGET_MAVERICK && TARGET_IEEE)"
   ""
 )
 
--- gcc-4.3.2/gcc/config/arm/cirrus.md.old	2008-12-03 12:13:08.000000000 +0000
+++ gcc-4.3.2/gcc/config/arm/cirrus.md	2008-12-04 14:01:59.000000000 +0000
@@ -101,11 +101,12 @@
    (set_attr "cirrus" "normal")]
 )
 
+; Cirrus hardware bug: denormalized values on input are truncated to zero
 (define_insn "*cirrus_addsf3"
   [(set (match_operand:SF          0 "cirrus_fp_register" "=v")
 	(plus:SF (match_operand:SF 1 "cirrus_fp_register" "v")
 		 (match_operand:SF 2 "cirrus_fp_register" "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfadds%?\\t%V0, %V1, %V2"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -115,7 +116,7 @@
   [(set (match_operand:DF          0 "cirrus_fp_register" "=v")
 	(plus:DF (match_operand:DF 1 "cirrus_fp_register" "v")
 		 (match_operand:DF 2 "cirrus_fp_register" "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfaddd%?\\t%V0, %V1, %V2"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -145,7 +146,7 @@
   [(set (match_operand:SF           0 "cirrus_fp_register" "=v")
 	(minus:SF (match_operand:SF 1 "cirrus_fp_register"  "v")
 		  (match_operand:SF 2 "cirrus_fp_register"  "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfsubs%?\\t%V0, %V1, %V2"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -155,7 +156,7 @@
   [(set (match_operand:DF           0 "cirrus_fp_register" "=v")
 	(minus:DF (match_operand:DF 1 "cirrus_fp_register" "v")
 		  (match_operand:DF 2 "cirrus_fp_register" "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfsubd%?\\t%V0, %V1, %V2"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -316,10 +317,12 @@
 )
 
 ; Cirrus hardware bug: neg 0 -> 0 instead of -0
+; Cirrus hardware bug: denormalized values on input are truncated to zero
 (define_insn "*cirrus_negsf2"
   [(set (match_operand:SF         0 "cirrus_fp_register" "=v")
 	(neg:SF (match_operand:SF 1 "cirrus_fp_register"  "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! HONOR_SIGNED_ZEROS (SFmode)"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK
+   && ! HONOR_SIGNED_ZEROS (SFmode) && ! TARGET_IEEE"
   "cfnegs%?\\t%V0, %V1"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -328,7 +331,8 @@
 (define_insn "*cirrus_negdf2"
   [(set (match_operand:DF         0 "cirrus_fp_register" "=v")
 	(neg:DF (match_operand:DF 1 "cirrus_fp_register"  "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! HONOR_SIGNED_ZEROS (DFmode)"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK
+   && ! HONOR_SIGNED_ZEROS (DFmode) && ! TARGET_IEEE"
   "cfnegd%?\\t%V0, %V1"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -345,10 +349,11 @@
    (set_attr "cirrus" "normal")]
 )
 
+; Cirrus hardware bug: denormalized values on input are truncated to zero
 (define_insn "*cirrus_abssf2"
   [(set (match_operand:SF         0 "cirrus_fp_register" "=v")
         (abs:SF (match_operand:SF 1 "cirrus_fp_register"  "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfabss%?\\t%V0, %V1"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -357,7 +362,7 @@
 (define_insn "*cirrus_absdf2"
   [(set (match_operand:DF         0 "cirrus_fp_register" "=v")
         (abs:DF (match_operand:DF 1 "cirrus_fp_register"  "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfabsd%?\\t%V0, %V1"
   [(set_attr "type" "farith")
    (set_attr "cirrus" "normal")]
@@ -423,20 +428,23 @@
    (set_attr "length" "8")]
 )
 
+; Cirrus hardware bugs: denormalized values on input are truncated to zero
+; and double-to-single float never produces denormalized values.
 (define_insn "*cirrus_truncdfsf2"
   [(set (match_operand:SF  0 "cirrus_fp_register" "=v")
         (float_truncate:SF
          (match_operand:DF 1 "cirrus_fp_register" "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfcvtds%?\\t%V0, %V1"
   [(set_attr "type" "f_cvt")
    (set_attr "cirrus" "normal")]
 )
 
+; Cirrus hardware bug: denormalized values on input are truncated to zero
 (define_insn "*cirrus_extendsfdf2"
   [(set (match_operand:DF                  0 "cirrus_fp_register" "=v")
         (float_extend:DF (match_operand:SF 1 "cirrus_fp_register"  "v")))]
-  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK"
+  "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_MAVERICK && ! TARGET_IEEE"
   "cfcvtsd%?\\t%V0, %V1"
   [(set_attr "type" "f_cvt")
    (set_attr "cirrus" "normal")]