Source file
test/simd/bug1.go
1
2
3
4
5
6
7
8
9
10
11 package p
12
13 import (
14 "simd"
15 "unsafe"
16 )
17
18 func F(
19 dst *[2][4][4]float32,
20 tos *[2][4][4]float32,
21 blend int,
22 ) {
23 tiny := simd.BroadcastFloat32x8(0)
24 for {
25 dstCol12 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][0:]))))
26 dstCol34 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][2:]))))
27 dstCol56 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][0:]))))
28 dstCol78 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][2:]))))
29
30 tosCol12 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[0][0:]))))
31 tosCol34 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[0][2:]))))
32 tosCol56 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[1][0:]))))
33 tosCol78 := simd.LoadFloat32x8((*[8]float32)(unsafe.Pointer((*[2][4]float32)(tos[1][2:]))))
34
35 var Cr0, Cr1, Cr2 simd.Float32x8
36 if blend != 0 {
37 invas := tosCol78.Max(tiny)
38 invad := dstCol78.Max(tiny)
39 Cd0 := dstCol12.Mul(invad)
40 Cd1 := dstCol34.Mul(invad)
41 Cd2 := dstCol56.Mul(invad)
42 Cs0 := tosCol12.Mul(invas)
43 Cs1 := tosCol34.Mul(invas)
44 Cs2 := tosCol56.Mul(invas)
45 var Cm0, Cm1, Cm2 simd.Float32x8
46 switch blend {
47 case 4:
48 case 10:
49 case 11:
50 case 8:
51 case 5:
52 case 1:
53 case 0:
54 Cm1 = Cs1
55 case 2:
56 Cm0 = Cd0.Add(Cs0)
57 Cm1 = Cd1.Add(Cs1)
58 Cm2 = Cd2.Add(Cs2)
59 }
60 Cr0 = dstCol78.Mul(Cs0).Mul(Cm0)
61 Cr1 = dstCol78.Mul(Cs1).Mul(Cm1)
62 Cr2 = dstCol78.Mul(Cs2).Mul(Cm2)
63 }
64 var resR, resG, resB, resA simd.Float32x8
65 if blend == 0 {
66 resR = tosCol12
67 resG = tosCol34
68 resB = tosCol56
69 resA = tosCol78
70 } else {
71 resR = Cr0.Add(dstCol12)
72 resG = Cr1.Add(dstCol34)
73 resB = Cr2.Add(dstCol56)
74 }
75
76 resR.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][0:2]))))
77 resG.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[0][2:4]))))
78 resB.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][0:2]))))
79 resA.Store((*[8]float32)(unsafe.Pointer((*[2][4]float32)(dst[1][2:4]))))
80 }
81 }
82
View as plain text