Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
dnl  mpn_sqr_basecase for Pentium 4 and P6 models with SSE2 (i.e., 9,D,E,F).

dnl  Copyright 2001, 2002, 2007 Free Software Foundation, Inc.

dnl  This file is part of the GNU MP Library.
dnl
dnl  The GNU MP Library is free software; you can redistribute it and/or modify
dnl  it under the terms of either:
dnl
dnl    * the GNU Lesser General Public License as published by the Free
dnl      Software Foundation; either version 3 of the License, or (at your
dnl      option) any later version.
dnl
dnl  or
dnl
dnl    * the GNU General Public License as published by the Free Software
dnl      Foundation; either version 2 of the License, or (at your option) any
dnl      later version.
dnl
dnl  or both in parallel, as here.
dnl
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dnl  for more details.
dnl
dnl  You should have received copies of the GNU General Public License and the
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
dnl  see https://www.gnu.org/licenses/.

include(`../config.m4')

C TODO:
C  * Improve ad-hoc outer loop code and register handling.  Some feed-in
C    scheduling could improve things by several cycles per outer iteration.
C  * In Lam3...Lam1 code for, keep accumulation operands in registers, without
C    storing intermediates to rp.
C  * We might want to keep 32 in a free mm register, since the register form is
C    3 bytes and the immediate form is 4 bytes.  About 80 bytes to save.
C  * Look into different loop alignment, we now expand the code about 50 bytes
C    with possibly needless alignment.
C  * Use OSP, should solve feed-in latency problems.
C  * Address relative slowness for un<=3 for Pentium M.  The old code is there
C    considerably faster.  (1:20/14, 2:34:32, 3:66/57)

C INPUT PARAMETERS
C rp		sp + 4
C up		sp + 8
C un		sp + 12

	TEXT
	ALIGN(16)
PROLOGUE(mpn_sqr_basecase)
	mov	4(%esp), %edx		C rp
	mov	8(%esp), %eax		C up
	mov	12(%esp), %ecx		C un

	cmp	$2, %ecx
	jc	L(un1)
	jz	L(un2)
	cmp	$4, %ecx
	jc	L(un3)
	jz	L(un4)
	jmp	L(big)

L(un1):	mov	(%eax), %eax
	mov	%edx, %ecx
	mul	%eax
	mov	%eax, (%ecx)
	mov	%edx, 4(%ecx)
	ret
L(un2):	movd	(%eax), %mm0		C				un=2
	movd	(%eax), %mm2		C				un=2
	movd	4(%eax), %mm1		C				un=2
	pmuludq	%mm0, %mm0		C 64b weight 0			un=2
	pmuludq	%mm1, %mm2		C 64b weight 32			un=2
	pmuludq	%mm1, %mm1		C 64b weight 64			un=2
	movd	%mm0, (%edx)		C				un=2
	psrlq	$32, %mm0		C 32b weight 32			un=2
	pcmpeqd	%mm7, %mm7		C				un=2
	psrlq	$33, %mm7		C 0x000000007FFFFFFF		un=2
	pand	%mm2, %mm7		C 31b weight 32			un=2
	psrlq	$31, %mm2		C 33b weight 65			un=2
	psllq	$1, %mm7		C 31b weight 33			un=2
	paddq	%mm7, %mm0		C				un=2
	movd	%mm0, 4(%edx)		C				un=2
	psrlq	$32, %mm0		C				un=2
	paddq	%mm2, %mm1		C				un=2
	paddq	%mm0, %mm1		C				un=2
	movd	%mm1, 8(%edx)		C				un=2
	psrlq	$32, %mm1		C				un=2
	movd	%mm1, 12(%edx)		C				un=2
	emms
	ret
L(un3):	movd	(%eax), %mm7		C				un=3
	movd	4(%eax), %mm6		C				un=3
	pmuludq	%mm7, %mm6		C				un=3
	movd	8(%eax), %mm2		C				un=3
	pmuludq	%mm7, %mm2		C				un=3
	movd	%mm6, 4(%edx)		C				un=3
	psrlq	$32, %mm6		C				un=3
	paddq	%mm2, %mm6		C				un=3
	movd	%mm6, 8(%edx)		C				un=3
	psrlq	$32, %mm6		C				un=3
	movd	%mm6, 12(%edx)		C				un=3
	lea	4(%edx), %edx		C				un=3
	lea	4(%eax), %eax		C				un=3
	jmp	L(am1)
L(un4):	movd	(%eax), %mm7		C				un=4
	movd	4(%eax), %mm6		C				un=4
	pmuludq	%mm7, %mm6		C				un=4
	movd	8(%eax), %mm0		C				un=4
	pmuludq	%mm7, %mm0		C				un=4
	movd	12(%eax), %mm1		C				un=4
	pmuludq	%mm7, %mm1		C				un=4
	movd	%mm6, 4(%edx)		C				un=4
	psrlq	$32, %mm6		C				un=4
	paddq	%mm0, %mm6		C				un=4
	movd	%mm6, 8(%edx)		C				un=4
	psrlq	$32, %mm6		C				un=4
	paddq	%mm1, %mm6		C				un=4
	movd	%mm6, 12(%edx)		C				un=4
	psrlq	$32, %mm6		C				un=4
	movd	%mm6, 16(%edx)		C				un=4
	lea	4(%edx), %edx		C				un=4
	lea	4(%eax), %eax		C				un=4
	jmp	L(am2)

L(big):	push	%esi
	push	%ebx
	push	%edi
	pxor	%mm6, %mm6
	movd	(%eax), %mm7		C
	lea	4(%eax), %esi		C init up, up++
	lea	4(%eax), %eax		C up2++  FIXME: should fix offsets
	lea	4(%edx), %edi		C init rp, rp++
	lea	4(%edx), %edx		C rp2++
	lea	-4(%ecx), %ebx		C loop count
	and	$3, %ecx
	jz	L(3m)
	cmp	$2, %ecx
	ja	L(2m)
	jb	L(0m)

L(1m):
	movd	(%eax), %mm4		C				m 1
	lea	(%ebx), %ecx		C inner loop count		m 1
	pmuludq	%mm7, %mm4		C				m 1
	movd	4(%eax), %mm3		C				m 1
	pmuludq	%mm7, %mm3		C				m 1
	movd	8(%eax), %mm0		C				m 1
	jmp	L(m01)			C				m 1
	ALIGN(16)			C				m 1
L(lpm1):
	pmuludq	%mm7, %mm4		C				m 1
	paddq	%mm0, %mm6		C				m 1
	movd	4(%eax), %mm3		C				m 1
	movd	%mm6, -8(%edx)		C				m 1
	psrlq	$32, %mm6		C				m 1
	pmuludq	%mm7, %mm3		C				m 1
	paddq	%mm1, %mm6		C				m 1
	movd	8(%eax), %mm0		C				m 1
	movd	%mm6, -4(%edx)		C				m 1
	psrlq	$32, %mm6		C				m 1
L(m01):	pmuludq	%mm7, %mm0		C				m 1
	paddq	%mm4, %mm6		C				m 1
	movd	12(%eax), %mm1		C				m 1
	movd	%mm6, (%edx)		C				m 1
	psrlq	$32, %mm6		C				m 1
	pmuludq	%mm7, %mm1		C				m 1
	paddq	%mm3, %mm6		C				m 1
	movd	16(%eax), %mm4		C				m 1
	movd	%mm6, 4(%edx)		C				m 1
	psrlq	$32, %mm6		C				m 1
	lea	16(%eax), %eax		C				m 1
	lea	16(%edx), %edx		C				m 1
	sub	$4, %ecx		C				m 1
	ja	L(lpm1)			C				m 1
	pmuludq	%mm7, %mm4		C				m 1
	paddq	%mm0, %mm6		C				m 1
	movd	%mm6, -8(%edx)		C				m 1
	psrlq	$32, %mm6		C				m 1
	paddq	%mm1, %mm6		C				m 1
	jmp	L(0)

L(2m):
	movd	(%eax), %mm1		C				m 2
	lea	(%ebx), %ecx		C inner loop count		m 2
	pmuludq	%mm7, %mm1		C				m 2
	movd	4(%eax), %mm4		C				m 2
	pmuludq	%mm7, %mm4		C				m 2
	movd	8(%eax), %mm3		C				m 2
	jmp	L(m10)			C				m 2
	ALIGN(16)			C				m 2
L(lpm2):
	pmuludq	%mm7, %mm4		C				m 2
	paddq	%mm0, %mm6		C				m 2
	movd	8(%eax), %mm3		C				m 2
	movd	%mm6, -4(%edx)		C				m 2
	psrlq	$32, %mm6		C				m 2
L(m10):	pmuludq	%mm7, %mm3		C				m 2
	paddq	%mm1, %mm6		C				m 2
	movd	12(%eax), %mm0		C				m 2
	movd	%mm6, (%edx)		C				m 2
	psrlq	$32, %mm6		C				m 2
	pmuludq	%mm7, %mm0		C				m 2
	paddq	%mm4, %mm6		C				m 2
	movd	16(%eax), %mm1		C				m 2
	movd	%mm6, 4(%edx)		C				m 2
	psrlq	$32, %mm6		C				m 2
	pmuludq	%mm7, %mm1		C				m 2
	paddq	%mm3, %mm6		C				m 2
	movd	20(%eax), %mm4		C				m 2
	movd	%mm6, 8(%edx)		C				m 2
	psrlq	$32, %mm6		C				m 2
	lea	16(%eax), %eax		C				m 2
	lea	16(%edx), %edx		C				m 2
	sub	$4, %ecx		C				m 2
	ja	L(lpm2)			C				m 2
	pmuludq	%mm7, %mm4		C				m 2
	paddq	%mm0, %mm6		C				m 2
	movd	%mm6, -4(%edx)		C				m 2
	psrlq	$32, %mm6		C				m 2
	paddq	%mm1, %mm6		C				m 2
	jmp	L(1)

L(3m):
	movd	(%eax), %mm0		C				m 3
	lea	(%ebx), %ecx		C inner loop count		m 3
	pmuludq	%mm7, %mm0		C				m 3
	movd	4(%eax), %mm1		C				m 3
	pmuludq	%mm7, %mm1		C				m 3
	movd	8(%eax), %mm4		C				m 3
	jmp	L(lpm3)			C				m 3
	ALIGN(16)			C				m 3
L(lpm3):
	pmuludq	%mm7, %mm4		C				m 3
	paddq	%mm0, %mm6		C				m 3
	movd	12(%eax), %mm3		C				m 3
	movd	%mm6, (%edx)		C				m 3
	psrlq	$32, %mm6		C				m 3
	pmuludq	%mm7, %mm3		C				m 3
	paddq	%mm1, %mm6		C				m 3
	movd	16(%eax), %mm0		C				m 3
	movd	%mm6, 4(%edx)		C				m 3
	psrlq	$32, %mm6		C				m 3
	pmuludq	%mm7, %mm0		C				m 3
	paddq	%mm4, %mm6		C				m 3
	movd	20(%eax), %mm1		C				m 3
	movd	%mm6, 8(%edx)		C				m 3
	psrlq	$32, %mm6		C				m 3
	pmuludq	%mm7, %mm1		C				m 3
	paddq	%mm3, %mm6		C				m 3
	movd	24(%eax), %mm4		C				m 3
	movd	%mm6, 12(%edx)		C				m 3
	psrlq	$32, %mm6		C				m 3
	lea	16(%eax), %eax		C				m 3
	lea	16(%edx), %edx		C				m 3
	sub	$4, %ecx		C				m 3
	ja	L(lpm3)			C				m 3
	pmuludq	%mm7, %mm4		C				m 3
	paddq	%mm0, %mm6		C				m 3
	movd	%mm6, (%edx)		C				m 3
	psrlq	$32, %mm6		C				m 3
	paddq	%mm1, %mm6		C				m 3
	jmp	L(2)

L(0m):
	movd	(%eax), %mm3		C				m 0
	lea	(%ebx), %ecx		C inner loop count		m 0
	pmuludq	%mm7, %mm3		C				m 0
	movd	4(%eax), %mm0		C				m 0
	pmuludq	%mm7, %mm0		C				m 0
	movd	8(%eax), %mm1		C				m 0
	jmp	L(m00)			C				m 0
	ALIGN(16)			C				m 0
L(lpm0):
	pmuludq	%mm7, %mm4		C				m 0
	paddq	%mm0, %mm6		C				m 0
	movd	(%eax), %mm3		C				m 0
	movd	%mm6, -12(%edx)		C				m 0
	psrlq	$32, %mm6		C				m 0
	pmuludq	%mm7, %mm3		C				m 0
	paddq	%mm1, %mm6		C				m 0
	movd	4(%eax), %mm0		C				m 0
	movd	%mm6, -8(%edx)		C				m 0
	psrlq	$32, %mm6		C				m 0
	pmuludq	%mm7, %mm0		C				m 0
	paddq	%mm4, %mm6		C				m 0
	movd	8(%eax), %mm1		C				m 0
	movd	%mm6, -4(%edx)		C				m 0
	psrlq	$32, %mm6		C				m 0
L(m00):	pmuludq	%mm7, %mm1		C				m 0
	paddq	%mm3, %mm6		C				m 0
	movd	12(%eax), %mm4		C				m 0
	movd	%mm6, (%edx)		C				m 0
	psrlq	$32, %mm6		C				m 0
	lea	16(%eax), %eax		C				m 0
	lea	16(%edx), %edx		C				m 0
	sub	$4, %ecx		C				m 0
	ja	L(lpm0)			C				m 0
	pmuludq	%mm7, %mm4		C				m 0
	paddq	%mm0, %mm6		C				m 0
	movd	%mm6, -12(%edx)		C				m 0
	psrlq	$32, %mm6		C				m 0
	paddq	%mm1, %mm6		C				m 0
	jmp	L(3)

L(outer):
	lea	8(%edi), %edi		C rp += 2
	movd	(%esi), %mm7		C				am 3
	mov	%edi, %edx		C rp2 = rp			am 3
	lea	4(%esi), %esi		C up++				am 3
	lea	(%esi), %eax		C up2 = up			am 3
	movd	(%eax), %mm0		C				am 3
	lea	(%ebx), %ecx		C inner loop count		am 3
	pxor	%mm6, %mm6		C				am 3
	pmuludq	%mm7, %mm0		C				am 3
	movd	4(%eax), %mm1		C				am 3
	movd	(%edx), %mm4		C				am 3
	pmuludq	%mm7, %mm1		C				am 3
	movd	8(%eax), %mm2		C				am 3
	paddq	%mm0, %mm4		C				am 3
	movd	4(%edx), %mm5		C				am 3
	jmp	L(lam3)			C				am 3
	ALIGN(16)			C				am 3
L(lam3):
	pmuludq	%mm7, %mm2		C				am 3
	paddq	%mm4, %mm6		C				am 3
	movd	12(%eax), %mm3		C				am 3
	paddq	%mm1, %mm5		C				am 3
	movd	8(%edx), %mm4		C				am 3
	movd	%mm6, (%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	pmuludq	%mm7, %mm3		C				am 3
	paddq	%mm5, %mm6		C				am 3
	movd	16(%eax), %mm0		C				am 3
	paddq	%mm2, %mm4		C				am 3
	movd	12(%edx), %mm5		C				am 3
	movd	%mm6, 4(%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	pmuludq	%mm7, %mm0		C				am 3
	paddq	%mm4, %mm6		C				am 3
	movd	20(%eax), %mm1		C				am 3
	paddq	%mm3, %mm5		C				am 3
	movd	16(%edx), %mm4		C				am 3
	movd	%mm6, 8(%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	pmuludq	%mm7, %mm1		C				am 3
	paddq	%mm5, %mm6		C				am 3
	movd	24(%eax), %mm2		C				am 3
	paddq	%mm0, %mm4		C				am 3
	movd	20(%edx), %mm5		C				am 3
	movd	%mm6, 12(%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	lea	16(%eax), %eax		C				am 3
	lea	16(%edx), %edx		C				am 3
	sub	$4, %ecx		C				am 3
	ja	L(lam3)			C				am 3
	pmuludq	%mm7, %mm2		C				am 3
	paddq	%mm4, %mm6		C				am 3
	paddq	%mm1, %mm5		C				am 3
	movd	8(%edx), %mm4		C				am 3
	movd	%mm6, (%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	paddq	%mm5, %mm6		C				am 3
	paddq	%mm2, %mm4		C				am 3
L(2):	movd	%mm6, 4(%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	paddq	%mm4, %mm6		C				am 3
	movd	%mm6, 8(%edx)		C				am 3
	psrlq	$32, %mm6		C				am 3
	movd	%mm6, 12(%edx)		C				am 3

	lea	8(%edi), %edi		C rp += 2
	movd	(%esi), %mm7		C				am 2
	mov	%edi, %edx		C rp2 = rp			am 2
	lea	4(%esi), %esi		C up++				am 2
	lea	(%esi), %eax		C up2 = up			am 2
	movd	(%eax), %mm1		C				am 2
	lea	(%ebx), %ecx		C inner loop count		am 2
	pxor	%mm6, %mm6		C				am 2
	pmuludq	%mm7, %mm1		C				am 2
	movd	4(%eax), %mm2		C				am 2
	movd	(%edx), %mm5		C				am 2
	pmuludq	%mm7, %mm2		C				am 2
	movd	8(%eax), %mm3		C				am 2
	paddq	%mm1, %mm5		C				am 2
	movd	4(%edx), %mm4		C				am 2
	jmp	L(am10)			C				am 2
	ALIGN(16)			C				am 2
L(lam2):
	pmuludq	%mm7, %mm2		C				am 2
	paddq	%mm4, %mm6		C				am 2
	movd	8(%eax), %mm3		C				am 2
	paddq	%mm1, %mm5		C				am 2
	movd	4(%edx), %mm4		C				am 2
	movd	%mm6, -4(%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
L(am10):
	pmuludq	%mm7, %mm3		C				am 2
	paddq	%mm5, %mm6		C				am 2
	movd	12(%eax), %mm0		C				am 2
	paddq	%mm2, %mm4		C				am 2
	movd	8(%edx), %mm5		C				am 2
	movd	%mm6, (%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
	pmuludq	%mm7, %mm0		C				am 2
	paddq	%mm4, %mm6		C				am 2
	movd	16(%eax), %mm1		C				am 2
	paddq	%mm3, %mm5		C				am 2
	movd	12(%edx), %mm4		C				am 2
	movd	%mm6, 4(%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
	pmuludq	%mm7, %mm1		C				am 2
	paddq	%mm5, %mm6		C				am 2
	movd	20(%eax), %mm2		C				am 2
	paddq	%mm0, %mm4		C				am 2
	movd	16(%edx), %mm5		C				am 2
	movd	%mm6, 8(%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
	lea	16(%eax), %eax		C				am 2
	lea	16(%edx), %edx		C				am 2
	sub	$4, %ecx		C				am 2
	ja	L(lam2)			C				am 2
	pmuludq	%mm7, %mm2		C				am 2
	paddq	%mm4, %mm6		C				am 2
	paddq	%mm1, %mm5		C				am 2
	movd	4(%edx), %mm4		C				am 2
	movd	%mm6, -4(%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
	paddq	%mm5, %mm6		C				am 2
	paddq	%mm2, %mm4		C				am 2
L(1):	movd	%mm6, (%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
	paddq	%mm4, %mm6		C				am 2
	movd	%mm6, 4(%edx)		C				am 2
	psrlq	$32, %mm6		C				am 2
	movd	%mm6, 8(%edx)		C				am 2

	lea	8(%edi), %edi		C rp += 2
	movd	(%esi), %mm7		C				am 1
	mov	%edi, %edx		C rp2 = rp			am 1
	lea	4(%esi), %esi		C up++				am 1
	lea	(%esi), %eax		C up2 = up			am 1
	movd	(%eax), %mm2		C				am 1
	lea	(%ebx), %ecx		C inner loop count		am 1
	pxor	%mm6, %mm6		C				am 1
	pmuludq	%mm7, %mm2		C				am 1
	movd	4(%eax), %mm3		C				am 1
	movd	(%edx), %mm4		C				am 1
	pmuludq	%mm7, %mm3		C				am 1
	movd	8(%eax), %mm0		C				am 1
	paddq	%mm2, %mm4		C				am 1
	movd	4(%edx), %mm5		C				am 1
	jmp	L(am01)			C				am 1
	ALIGN(16)			C				am 1
L(lam1):
	pmuludq	%mm7, %mm2		C				am 1
	paddq	%mm4, %mm6		C				am 1
	movd	4(%eax), %mm3		C				am 1
	paddq	%mm1, %mm5		C				am 1
	movd	(%edx), %mm4		C				am 1
	movd	%mm6, -8(%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
	pmuludq	%mm7, %mm3		C				am 1
	paddq	%mm5, %mm6		C				am 1
	movd	8(%eax), %mm0		C				am 1
	paddq	%mm2, %mm4		C				am 1
	movd	4(%edx), %mm5		C				am 1
	movd	%mm6, -4(%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
L(am01):
	pmuludq	%mm7, %mm0		C				am 1
	paddq	%mm4, %mm6		C				am 1
	movd	12(%eax), %mm1		C				am 1
	paddq	%mm3, %mm5		C				am 1
	movd	8(%edx), %mm4		C				am 1
	movd	%mm6, (%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
	pmuludq	%mm7, %mm1		C				am 1
	paddq	%mm5, %mm6		C				am 1
	movd	16(%eax), %mm2		C				am 1
	paddq	%mm0, %mm4		C				am 1
	movd	12(%edx), %mm5		C				am 1
	movd	%mm6, 4(%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
	lea	16(%eax), %eax		C				am 1
	lea	16(%edx), %edx		C				am 1
	sub	$4, %ecx		C				am 1
	ja	L(lam1)			C				am 1
	pmuludq	%mm7, %mm2		C				am 1
	paddq	%mm4, %mm6		C				am 1
	paddq	%mm1, %mm5		C				am 1
	movd	(%edx), %mm4		C				am 1
	movd	%mm6, -8(%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
	paddq	%mm5, %mm6		C				am 1
	paddq	%mm2, %mm4		C				am 1
L(0):	movd	%mm6, -4(%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
	paddq	%mm4, %mm6		C				am 1
	movd	%mm6, (%edx)		C				am 1
	psrlq	$32, %mm6		C				am 1
	movd	%mm6, 4(%edx)		C				am 1

	lea	8(%edi), %edi		C rp += 2
	movd	(%esi), %mm7		C				am 0
	mov	%edi, %edx		C rp2 = rp			am 0
	lea	4(%esi), %esi		C up++				am 0
	lea	(%esi), %eax		C up2 = up			am 0
	movd	(%eax), %mm3		C				am 0
	lea	(%ebx), %ecx		C inner loop count		am 0
	pxor	%mm6, %mm6		C				am 0
	pmuludq	%mm7, %mm3		C				am 0
	movd	4(%eax), %mm0		C				am 0
	movd	(%edx), %mm5		C				am 0
	pmuludq	%mm7, %mm0		C				am 0
	movd	8(%eax), %mm1		C				am 0
	paddq	%mm3, %mm5		C				am 0
	movd	4(%edx), %mm4		C				am 0
	jmp	L(am00)			C				am 0
	ALIGN(16)			C				am 0
L(lam0):
	pmuludq	%mm7, %mm2		C				am 0
	paddq	%mm4, %mm6		C				am 0
	movd	(%eax), %mm3		C				am 0
	paddq	%mm1, %mm5		C				am 0
	movd	-4(%edx), %mm4		C				am 0
	movd	%mm6, -12(%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
	pmuludq	%mm7, %mm3		C				am 0
	paddq	%mm5, %mm6		C				am 0
	movd	4(%eax), %mm0		C				am 0
	paddq	%mm2, %mm4		C				am 0
	movd	(%edx), %mm5		C				am 0
	movd	%mm6, -8(%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
	pmuludq	%mm7, %mm0		C				am 0
	paddq	%mm4, %mm6		C				am 0
	movd	8(%eax), %mm1		C				am 0
	paddq	%mm3, %mm5		C				am 0
	movd	4(%edx), %mm4		C				am 0
	movd	%mm6, -4(%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
L(am00):
	pmuludq	%mm7, %mm1		C				am 0
	paddq	%mm5, %mm6		C				am 0
	movd	12(%eax), %mm2		C				am 0
	paddq	%mm0, %mm4		C				am 0
	movd	8(%edx), %mm5		C				am 0
	movd	%mm6, (%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
	lea	16(%eax), %eax		C				am 0
	lea	16(%edx), %edx		C				am 0
	sub	$4, %ecx		C				am 0
	ja	L(lam0)			C				am 0
	pmuludq	%mm7, %mm2		C				am 0
	paddq	%mm4, %mm6		C				am 0
	paddq	%mm1, %mm5		C				am 0
	movd	-4(%edx), %mm4		C				am 0
	movd	%mm6, -12(%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
	paddq	%mm5, %mm6		C				am 0
	paddq	%mm2, %mm4		C				am 0
L(3):	movd	%mm6, -8(%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
	paddq	%mm4, %mm6		C				am 0
	movd	%mm6, -4(%edx)		C				am 0
	psrlq	$32, %mm6		C				am 0
	movd	%mm6, (%edx)		C				am 0
	sub	$4, %ebx		C				am 0
	ja	L(outer)			C				am 0

	mov	%edi, %edx
	mov	%esi, %eax
	pop	%edi
	pop	%ebx
	pop	%esi

L(am3):	C up[un-1..un-3] x up[un-4]
	lea	8(%edx), %edx		C rp2 += 2
	movd	(%eax), %mm7
	movd	4(%eax), %mm1
	movd	8(%eax), %mm2
	movd	12(%eax), %mm3
	movd	(%edx), %mm4
	pmuludq	%mm7, %mm1
	movd	4(%edx), %mm5
	pmuludq	%mm7, %mm2
	movd	8(%edx), %mm6
	pmuludq	%mm7, %mm3
	paddq	%mm1, %mm4
	paddq	%mm2, %mm5
	paddq	%mm3, %mm6
	movd	%mm4, (%edx)
	psrlq	$32, %mm4
	paddq	%mm5, %mm4
	movd	%mm4, 4(%edx)
	psrlq	$32, %mm4
	paddq	%mm6, %mm4
	movd	%mm4, 8(%edx)
	psrlq	$32, %mm4
	movd	%mm4, 12(%edx)		C FIXME feed through!
	lea	4(%eax), %eax

L(am2):	C up[un-1..un-2] x up[un-3]
	lea	8(%edx), %edx		C rp2 += 2
	movd	(%eax), %mm7
	movd	4(%eax), %mm1
	movd	8(%eax), %mm2
	movd	(%edx), %mm4
	movd	4(%edx), %mm5
	pmuludq	%mm7, %mm1
	pmuludq	%mm7, %mm2
	paddq	%mm1, %mm4
	paddq	%mm2, %mm5
	movd	%mm4, (%edx)
	psrlq	$32, %mm4
	paddq	%mm5, %mm4
	movd	%mm4, 4(%edx)
	psrlq	$32, %mm4
	movd	%mm4, 8(%edx)		C FIXME feed through!
	lea	4(%eax), %eax

L(am1):	C up[un-1] x up[un-2]
	lea	8(%edx), %edx		C rp2 += 2
	movd	(%eax), %mm7
	movd	4(%eax), %mm2
	movd	(%edx), %mm4
	pmuludq	%mm7, %mm2
	paddq	%mm2, %mm4
	movd	%mm4, (%edx)
	psrlq	$32, %mm4
	movd	%mm4, 4(%edx)

C *** diag stuff, use elementary code for now

	mov	4(%esp), %edx		C rp
	mov	8(%esp), %eax		C up
	mov	12(%esp), %ecx		C un

	movd	(%eax), %mm2
	pmuludq	%mm2, %mm2		C src[0]^2

	pcmpeqd	%mm7, %mm7
	psrlq	$32, %mm7

	movd	4(%edx), %mm3		C dst[1]

	movd	%mm2, (%edx)
	psrlq	$32, %mm2

	psllq	$1, %mm3		C 2*dst[1]
	paddq	%mm3, %mm2
	movd	%mm2, 4(%edx)
	psrlq	$32, %mm2

	sub	$2, %ecx

L(diag):
	movd	4(%eax), %mm0		C src limb
	add	$4, %eax
	pmuludq	%mm0, %mm0
	movq	%mm7, %mm1
	pand	%mm0, %mm1		C diagonal low
	psrlq	$32, %mm0		C diagonal high

	movd	8(%edx), %mm3
	psllq	$1, %mm3		C 2*dst[i]
	paddq	%mm3, %mm1
	paddq	%mm1, %mm2
	movd	%mm2, 8(%edx)
	psrlq	$32, %mm2

	movd	12(%edx), %mm3
	psllq	$1, %mm3		C 2*dst[i+1]
	paddq	%mm3, %mm0
	paddq	%mm0, %mm2
	movd	%mm2, 12(%edx)
	add	$8, %edx
	psrlq	$32, %mm2

	sub	$1, %ecx
	jnz	L(diag)

	movd	4(%eax), %mm0		C src[size-1]
	pmuludq	%mm0, %mm0
	pand	%mm0, %mm7		C diagonal low
	psrlq	$32, %mm0		C diagonal high

	movd	8(%edx), %mm3		C dst[2*size-2]
	psllq	$1, %mm3
	paddq	%mm3, %mm7
	paddq	%mm7, %mm2
	movd	%mm2, 8(%edx)
	psrlq	$32, %mm2

	paddq	%mm0, %mm2
	movd	%mm2, 12(%edx)		C dst[2*size-1]

	emms
	ret

EPILOGUE()