Use top-level instances to solve superclasses where possible
[ghc.git] / testsuite / tests / perf / should_run / all.T
1 # T12791 and T5835 test that GHC uses top-level instances in places where using
2 # a locally given solution would produce worse code.
3 # See Note [Solving from instances when interacting Dicts]
4
5 test('T5835',
6      [stats_num_field('max_bytes_used',
7            [(wordsize(64), 44312, 10)]),
8        only_ways(['normal'])
9        ],
10      compile_and_run,
11      ['-O'])
12
13 test('T12791',
14      [stats_num_field('max_bytes_used',
15            [(wordsize(64), 44312, 10)]),
16        only_ways(['normal'])
17        ],
18      compile_and_run,
19      ['-O'])
20
21 # Tests that newArray/newArray_ is being optimised correctly
22
23 test('T10359',
24      [stats_num_field('bytes allocated',
25           [(wordsize(64), 499512, 5),
26            (wordsize(32), 351508, 5)]),
27       only_ways(['normal'])
28       ],
29      compile_and_run,
30      ['-O'])
31
32 # fortunately the values here are mostly independent of the wordsize,
33 # because the test allocates an unboxed array of doubles.
34 test('T3586',
35      [stats_num_field('peak_megabytes_allocated', (17, 1)),
36                                  # expected value: 17 (amd64/Linux)
37       stats_num_field('bytes allocated', (16102024, 5)),
38                         # prev:           16835544 (amd64/Linux)
39                         # 2014-07-17:     16102024 (amd64/Linux), general round of updates
40       only_ways(['normal']),
41
42       # Use `+RTS -G1` for more stable residency measurements. Note [residency].
43       # Only 64-bit as we don't have a good 32-bit test environment at the moment
44       when(wordsize(64), extra_hc_opts('+RTS -G1 -RTS'))
45       ],
46      compile_and_run,
47      ['-O'])
48
49 test('T4830',
50      [stats_num_field('bytes allocated',
51           [(wordsize(64), 98248, 4),
52            #             127000 (amd64/Linux)
53            # 2013-02-07:  99264 (amd64/Linux)
54            # 2014-01-13:  98248 (amd64/Linux) due to #8647
55            # 2015-04-03: Widen 1->4% (amd64/Windows was doing better)
56            (wordsize(32), 70646, 3)]),
57            # 2013-02-10:  69744 (x86/Windows)
58            # 2013-02-10:  71548 (x86/OSX)
59            # 2014-01-28:  Widen range 2->3
60            #                (x86/Windows - actual 69000, lower was 69233)
61       only_ways(['normal'])
62       ],
63      compile_and_run,
64      ['-O2'])
65
66 test('T3245', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
67      compile_and_run, ['-O'])
68
69 # Test that bytestring reading/writing isn't over-allocating.  We had
70 # a bug in hGetBufNonBlocking in 6.13 that triggered this.
71 #
72 test('lazy-bs-alloc',
73      [stats_num_field('peak_megabytes_allocated', (2, 1)),
74                                  # expected value: 2 (amd64/Linux)
75       stats_num_field('bytes allocated',
76           [(wordsize(64), 444720, 5),
77             #             489776 (amd64/Linux)
78             # 2013-02-07: 429744 (amd64/Linux)
79             # 2013-12-12: 425400 (amd64/Linux)
80             # 2015-04-04: Widen 1->3% (amd64/Windows was failing)
81             # 2015-08-15: 431500 (Windows not good enough. avg of Windows&Linux)
82             # 2015-12-15: 444720 (amd64/Linux, D1616)
83             # 2015-12-17: 444720 (widen 3->5%, Windows is at 462688)
84            (wordsize(32), 429760, 2)]),
85             # 2013-02-10: 421296 (x86/Windows)
86             # 2013-02-10: 414180 (x86/OSX)
87             # 2014-01-22: 411500 (x86/Linux)
88             # 2014-01-28: Widen 1->2% (x86/Windows was at 425212)
89             # 2016-04-06: 429760 (x86/Linux) no idea what happened
90       only_ways(['normal']),
91       extra_run_opts('arith011.stdout'),
92       ignore_stdout,
93
94       # Use `+RTS -G1` for more stable residency measurements. Note [residency].
95       # Only 64-bit as we don't have a good 32-bit test environment at the moment
96       when(wordsize(64), extra_hc_opts('+RTS -G1 -RTS'))
97       ],
98      # use a suitably big file, without bloating the repo with a new one:
99      compile_and_run,
100      ['-O'])
101
102 test('T876',
103      [stats_num_field('bytes allocated',
104           [(platform('x86_64-unknown-mingw32'), 66928, 5),
105               # 2015-04-03: 71904 (amd64/Windows, unknown cause)
106               # 2016-11-27: 66928 (amd64/Windows, unknown cause)
107            (wordsize(64), 58128, 5),
108               # 2013-02-14: 1263712 (x86_64/Linux)
109               # 2014-02-10:   63216 (x86_64/Linux), call arity analysis
110               # 2016-11-11:   58128 (x86_64/Linux), it's not clear
111
112            (wordsize(32), 53156, 5) ]),
113               # some date:  663712  (Windows, 64-bit machine)
114               # 2014-04-04:  56820  (Windows, 64-bit machine)
115               # 2014-06-29:  53024  (x86_64/Linux)
116               # 2014-12-01:  56796  (Windows)
117               # 2015-07-11:  53156  (x86_64/Linux)
118
119       only_ways(['normal']),
120       extra_run_opts('10000')
121       ],
122      compile_and_run,
123      ['-O'])
124
125 # Get reproducible floating-point results on x86
126 if config.arch == 'i386':
127    sse2_opts = '-msse2'
128 else:
129    sse2_opts = ''
130
131 test('T4321',
132      omit_ways(['ghci']),
133      compile_and_run, ['-O ' + sse2_opts])
134
135 test('T3736', [], run_command, ['$MAKE -s --no-print-directory T3736'])
136 test('T3738',
137      [extra_clean(['T3738a.hi', 'T3738a.o']),
138       stats_num_field('peak_megabytes_allocated', (2, 0)),
139                     # expected value: 1 (amd64/Linux)
140                     # 2016-08-31:     2 (allocation area size bumped to 1MB)
141       stats_num_field('bytes allocated',
142                       [(wordsize(32), 45648, 5),
143                     # expected value: 50520 (x86/Linux)
144                        (wordsize(64), 50592, 8)]),
145                     # prev:           49400 (amd64/Linux)
146                     # 2014-07-17:     50520 (amd64/Linux) general round of updates
147                     # 2014-09-10:     50592 (amd64/Linux) post-AMP-update
148                     # 2015-04-03: Widen 5->8% (amd64/Windows was doing better)
149       only_ways(['normal'])
150       ],
151      compile_and_run,
152      ['-O'])
153
154 test('MethSharing',
155      [stats_num_field('peak_megabytes_allocated', (2, 0)),
156                     # expected value: 1 (amd64/Linux)
157                     # 2016-08-31:     2 (allocation area size bumped to 1MB)
158       stats_num_field('bytes allocated',
159                       [(wordsize(32), 360940756, 5),
160                     # expected value: 2685858140 (x86/OS X)
161                           # expected: 360940756 (x86/Linux)
162                        (wordsize(64), 640067672, 5)]),
163                           # expected: 640067672 (amd64/Linux)
164       only_ways(['normal'])
165       ],
166      compile_and_run,
167      ['-O'])
168 test('T2902', [], run_command, ['$MAKE -s --no-print-directory T2902'])
169 test('T149',
170      [ # expect_broken(149),
171        # working (2 Jul 2013, x86-64/Linux)
172       extra_clean(['T149_A',    'T149_B',
173                    'T149_A.hi', 'T149_B.hi',
174                    'T149_A.o',  'T149_B.o'])],
175      run_command,
176      ['$MAKE -s --no-print-directory T149'])
177
178 test('T5113',
179      [stats_num_field('bytes allocated',
180                       [(wordsize(32), 4000000, 5),
181                        (wordsize(64), 8000000, 5)]),
182       only_ways(['normal'])
183       ],
184      compile_and_run,
185      ['-O'])
186
187
188 test('T4978',
189      [stats_num_field('bytes allocated',
190                       [(wordsize(32), 10000000, 5),
191                        (wordsize(64), 10137680, 5)]),
192                     # expected value: 10137680 (amd64/Linux)
193       only_ways(['normal'])
194       ],
195      compile_and_run,
196      ['-O2'])
197
198 test('T5205',
199      [stats_num_field('bytes allocated',
200                       [(wordsize(32), 47088, 5),
201                     # expected value: 47088 (x86/Darwin)
202
203                        (platform('x86_64-unknown-mingw32'), 52264, 5),
204                     # 2016-12-14: 52264 (Separate out Windows results)
205
206                        (wordsize(64), 56208, 5)]),
207                     # expected value: 51320 (amd64/Linux)
208                     # 2014-07-17:     52600 (amd64/Linux) general round of updates
209                     # 2015-04-03: Widen 5->7% (amd64/Windows was doing better)
210                     # 2015-08-15: 50648 (Windows too good. avg of Windows&Linux)
211                     # 2015-10-30: 56208 (D757: Emit Typeable at definition site)
212                     # 2016-12-14: Narrow 7->5% (Separate out Windows results)
213       only_ways(['normal', 'optasm'])
214       ],
215      compile_and_run,
216      [''])
217
218 test('T5549',
219      [stats_num_field('bytes allocated',
220                       [(wordsize(32), 4096606332, 5),
221                     # expected value: 3362958676 (Windows)
222                     # 2014-12-01:     4096606332 (Windows) integer-gmp2
223
224                        (wordsize(64), 5793140200, 5)]),
225                     # expected value: 6725846120 (amd64/Linux)
226                     #                 8193140752 (amd64/Linux) integer-gmp2
227                     #                 5793140200 (amd64/Linux) integer-gmp2
228       only_ways(['normal'])
229       ],
230      compile_and_run,
231      ['-O'])
232
233 test('T4474a',
234      [stats_num_field('bytes allocated',
235                       [(wordsize(32), 2405242767, 5),
236                        (wordsize(64), 4831890304, 5)]),
237                     # expected value: 4831890304 (amd64/OSX)
238       only_ways(['normal'])
239       ],
240      compile_and_run,
241      ['-O'])
242 test('T4474b',
243      [stats_num_field('bytes allocated',
244                       [(wordsize(32), 2405242767, 5),
245                        (wordsize(64), 4831890304, 5)]),
246                     # expected value: 4831890304 (amd64/OSX)
247       only_ways(['normal'])
248       ],
249      compile_and_run,
250      ['-O'])
251 test('T4474c',
252      [stats_num_field('bytes allocated',
253                       [(wordsize(32), 2405242767, 5),
254                        (wordsize(64), 4831890304, 5)]),
255                     # expected value: 4831890304 (amd64/OSX)
256       only_ways(['normal'])
257       ],
258      compile_and_run,
259      ['-O'])
260
261 test('T5237',
262      [stats_num_field('bytes allocated',
263                         [(platform('i386-unknown-mingw32'), 73280, 5),
264                          (wordsize(32), 78328, 5),
265                       # expected value: 78328 (i386/Linux)
266                          (wordsize(64), 104176, 5)]),
267                       # expected value: 110888 (amd64/Linux)
268                       # expected value: 104176 (amd64/Linux)
269      only_ways(['normal'])
270      ],
271     compile_and_run,
272     ['-O ' + sse2_opts])
273
274 test('T5536',
275      [stats_num_field('bytes allocated',
276                       [(wordsize(32), 446260520, 1),
277                                    # 1246287228 (i386/Linux)
278                                     # 446328556 (i386/Windows)
279                                     # 446192484 (i386/OSX)
280                        (wordsize(64), 892399040, 5)]),
281                    # expected value: 2492589480 (amd64/Linux)
282                    # 17/1/13:         892399040 (x86_64/Linux)
283                    #                  (new demand analyser)
284      extra_clean(['T5536.data']),
285      ignore_stdout,
286      only_ways(['normal'])
287      ],
288     compile_and_run,
289     ['-O'])
290
291 test('T7257',
292      [stats_num_field('bytes allocated',
293                       [(wordsize(32), 989850664, 10),
294                         # expected value: 1246287228 (i386/Linux)
295                         # 2016-04-06: 989850664 (i386/Linux) no idea what happened
296                        (wordsize(64), 1414893248, 5)]),
297                         # 2012-09-21: 1774893760 (amd64/Linux)
298                         # 2015-11-03: 1654893248 (amd64/Linux)
299                         # 2016-06-22: 1414893248 (amd64/Linux, sizeExpr fix)
300       stats_num_field('peak_megabytes_allocated',
301                       [(wordsize(32), 217, 5),
302                         # 2012-10-08: 217 (x86/Linux)
303                        (wordsize(64), 227, 5)]),
304                         # 2012-09-21: 227 (amd64/Linux)
305
306       only_ways(['normal'])
307      ],
308     compile_and_run, ['-O'])
309
310 test('Conversions',
311      [stats_num_field('bytes allocated',
312                       [(wordsize(32), 76768, 3),
313                         # 2012-12-18: 55316 Guessed 64-bit value / 2
314                         # 2013-02-10: 77472 (x86/OSX)
315                         # 2013-02-10: 79276 (x86/Windows)
316                         # 2014-01-13: 76768 (x86/Linux) due to #8647
317                        (wordsize(64), 107544, 5)]),
318                         # 2012-12-18: 109608 (amd64/OS X)
319                         # 2014-07-17: 107544 (amd64/Linux)
320
321       only_ways(['normal'])
322      ],
323     compile_and_run, ['-O -msse2'])
324
325 test('T7507', omit_ways(['ghci']), compile_and_run, ['-O'])
326 # For 7507, stack overflow is the bad case
327
328 test('T7436',
329      [stats_num_field('max_bytes_used',
330           [(wordsize(64), 60360, 4),
331            #             127000 (amd64/Linux)
332            # 2013-02-07:  60360 (amd64/Linux)
333            # 2015-04-03: Widen 1->4% (amd64/Windows was doing better)
334            (wordsize(32), 58434, 1)]),
335             # 2013-02-10: 58032 (x86/Windows)
336             # 2013-02-10: 58836 (x86/OSX)
337       only_ways(['normal'])
338       ],
339      compile_and_run,
340      ['-O'])
341
342 test('T7797',
343       [stats_num_field('bytes allocated',
344                       [(wordsize(32), 240044984, 5),
345                           # expected value: 2685858140 (x86/OS X)
346                           # expected: 360940756 (x86/Linux)
347                           # expected: 240044984 (x86/Windows, 64bit machine)
348                        (wordsize(64), 480050944, 5)]),
349                           # expected: 480050944 (amd64/Linux)
350       extra_clean(['T7797a.hi', 'T7797a.o']),
351       only_ways(['normal'])
352       ],
353      compile_and_run,
354      ['-O'])
355
356 test('T7954',
357       [stats_num_field('bytes allocated',
358                       [(wordsize(32), 920045264, 10),
359               # some date:  1380051408    (64-bit Windows machine)
360               # 2014-04-04:  920045264    (64-bit Windows machine)
361                        (wordsize(64), 1680051336, 10)]),
362               # 2014-02-10: 1680051336 (x86_64/Linux), call arity analysis
363       only_ways(['normal'])
364       ],
365      compile_and_run,
366      ['-O'])
367
368 test('T7850',
369      [stats_num_field('peak_megabytes_allocated',
370                       [(wordsize(32), 2, 10),
371                        (wordsize(64), 4, 10)]),
372       only_ways(['normal'])],
373      compile_and_run,
374      ['-O'])
375
376 test('T5949',
377      [stats_num_field('bytes allocated',
378                       [ (wordsize(32), 116020, 10),
379                         (wordsize(64), 201008, 10)]),
380                       # previously, it was >400000 bytes
381       only_ways(['normal'])],
382      compile_and_run,
383      ['-O'])
384
385 test('T4267',
386      [stats_num_field('bytes allocated',
387                       [ (wordsize(32), 36012, 10)
388                       # 32-bit value close to 64 bit; c.f. T7619
389                       , (wordsize(64), 40992, 10) ]),
390                       # previously, it was >170000 bytes
391                       # 2014-01-17: 130000
392                       # 2014-02-10: 40992 (x86_64/Linux), call arity analysis
393       only_ways(['normal'])],
394      compile_and_run,
395      ['-O'])
396
397 test('T7619',
398      [stats_num_field('bytes allocated',
399                       [ (wordsize(32), 36012, 10)
400                       # 32-bit close to 64-bit value; most of this very
401                       # small number is standard start-up boilerplate I think
402                       , (wordsize(64), 40992, 10) ]),
403                       # previously, it was >400000 bytes
404       only_ways(['normal'])],
405      compile_and_run,
406      ['-O'])
407
408 test('InlineArrayAlloc',
409      [stats_num_field('bytes allocated',
410                       [ (wordsize(32), 800040960, 5)
411                       , (wordsize(64), 1600040960, 5) ]),
412       only_ways(['normal'])],
413      compile_and_run,
414      ['-O2'])
415
416 test('InlineByteArrayAlloc',
417      [stats_num_field('bytes allocated',
418                       [ (wordsize(32), 1360036012, 5)
419                       , (wordsize(64), 1440040960, 5) ]),
420          # 32 and 64 bit not so different, because
421          # we are allocating *byte* arrays
422       only_ways(['normal'])],
423      compile_and_run,
424      ['-O2'])
425
426 test('InlineCloneArrayAlloc',
427      [stats_num_field('bytes allocated',
428                       [ (wordsize(32), 800041120, 5)
429                       , (wordsize(64), 1600041120, 5) ]),
430       only_ways(['normal'])],
431      compile_and_run,
432      ['-O2'])
433
434 test('T9203',
435      [stats_num_field('bytes allocated',
436                       [ (wordsize(32), 84345136 , 5)
437                       # was
438                       # 2016-04-06     84345136 (i386/Debian) not sure
439                       , (wordsize(64), 95451192, 5) ]),
440                       # was            95747304
441                       # 2019-09-10     94547280 post-AMP cleanup
442                       # 2015-10-28     95451192 emit Typeable at definition site
443       only_ways(['normal'])],
444      compile_and_run,
445      ['-O2'])
446
447 test('T9339',
448      [stats_num_field('bytes allocated',
449                       [ (wordsize(32),    40046844, 5)
450                       , (wordsize(64),    80050760, 5) ]),
451                       # w/o fusing last: 320005080
452                       # 2014-07-22:       80050760
453       only_ways(['normal'])],
454      compile_and_run,
455      ['-O2'])
456
457 test('T8472',
458      [stats_num_field('bytes allocated',
459                       [ (wordsize(32),    50000, 80)
460                       , (wordsize(64),    51424, 80) ]),
461       only_ways(['normal'])],
462      compile_and_run,
463      ['-O2'])
464
465 test('T12996',
466      [stats_num_field('bytes allocated',
467                       [ (wordsize(64),    76776, 5) ]),
468       only_ways(['normal'])],
469      compile_and_run,
470      ['-O2'])
471
472 test('T13001',
473      [stats_num_field('bytes allocated',
474                       [ (wordsize(32),    46728, 20)
475                       , (wordsize(64),    50600, 20) ]),
476       only_ways(['normal'])],
477      compile_and_run,
478      ['-O2'])
479
480 test('T12990',
481     [stats_num_field('bytes allocated',
482                      [ (wordsize(64), 21640904, 5) ]),
483                      # 2017-01-03     34440936  w/o inlining unsaturated
484                      #                          constructor wrappers
485                      # 2017-01-03     21640904 inline wrappers
486      only_ways(['normal'])],
487     compile_and_run,
488     ['-O2'])