- // input. This can be done juggling values in registers, with the
- // following fancy footwork: some row rotations, a transpose, and
- // some more rotations.
- vext.32 q9, q9, q9, #3 // 3, 4, 9, 14
- vext.32 q10, q10, q10, #2 // 2, 7, 8, 13
- vext.32 q11, q11, q11, #1 // 1, 6, 11, 12
-
- vzip.32 q0, q10 // 0, 2, 5, 7
- // 10, 8, 15, 13
- vzip.32 q11, q9 // 1, 3, 6, 4
- // 11, 9, 12, 14
-
- vzip.32 q0, q11 // 0, 1, 2, 3
- // 5, 6, 7, 4
- vzip.32 q10, q9 // 10, 11, 8, 9
- // 15, 12, 13, 14
-
- vext.32 q1, q11, q11, #3 // 4, 5, 6, 7
- vext.32 q2, q10, q10, #2 // 8, 9, 10, 11
- vext.32 q3, q9, q9, #1 // 12, 13, 14, 15
+ // input. The core trick is from Dan Bernstein's `armneon3'
+ // implementation, but with a lot of liposuction.
+ vmov q15, q0
+
+ // Sort out the columns by pairs.
+ vbif q0, q3, q12 // 0, 1, 10, 11
+ vbif q3, q2, q12 // 12, 13, 6, 7
+ vbif q2, q1, q12 // 8, 9, 2, 3
+ vbif q1, q15, q12 // 4, 5, 14, 15
+
+ // Now fix up the remaining discrepancies.
+ vswp D1(q0), D1(q2)
+ vswp D1(q1), D1(q3)