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r3nixG9ztjZnuyfLaLOtE3_4B2dbbYJ0xh_-QQlSsXVn9GJ2IUV2g0W3K4KqL7UOTyZT-4hpZ_Qpf0LVPW86Oo-_Vnr_AHv-yDC2rbCBFXY9Of_4yBEJcCQgJwG3kIBfRYI6EjQnQW8hQX8VCd-R8HMS_i0k_LtJVD6he85ZIHcWqHaWMwzpZY_JadLLPM9QAkcJckqVrlNJqdJ_7qZEHaUcvtqRKilVetPdlHxHyc8pVbpVJaVK37qO0n6HQ6GguFzJk-XqqMJu28Hhjnm_Z2K3-ekhnPjho__IHlimlzKdZEkQcabihyyNJkf7FoVeZrNeIGM8iaL17q27SuV_eYDz6bPdJafww8AfP44flhM-GsKQ8dHcH4Sj_mDUD0b9_tjj43DOBzD2HiI245Ga4CrdoTThG7fRzuyrGrw8NGcgJtSj-IKRNx4MvHHP4zAaDGHmD4PhiM6Hnb7HYyainsExWzIf0omFnGULhRcjobQ6XGRKiUXCuSWMDLXQEZ98PWwSFYc9lrudbqbYbXVL42HfbVwj5e2jD5b2xHL-H4qZKXA>53898</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Regression in register allocation from arm64 clang 11.0 and trunk
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
uncleasm
</td>
</tr>
</table>
<pre>
In the following "snippet" which is intended to compute tensor convolutions of size 1xHxW*8 * 8x3x3x16 using the naive
method for a block of 2x2x4 at a time, there seems to be some regression between clang-11.0 and trunk.
Full code available at https://godbolt.org/z/avz3hxKM7
With the trunk the inner loop has grown with about 50 instructions spilling the neon registers back and forth -- even when only about 24 registers are used. (Possible way to avoid could be to use fmla_laneq_f32 intrinsic, as now it seems that removing -ffast-math is also a disaster for clang-11.0 as the number of intermediate registers has probably grown.)
The other interesting issue is that redefining `WRONG_CODE_LEADING_TO_FEWER_PTRS 0` to use the actual algorithm, now it seems to me that more (internal) variables are generated to compute the pointers for `srcX, srcX +- stride`. One would expect that regardless of how the pointer arithmetic is implemented, those pointers would be allocated from a separate pool of general purpose registers -- but now clang-11.0 starts to spill again the NEON registers.
```
#include <cstdint>
#include "arm_neon.h"
#define WRONG_CODE_LEADING_TO_FEWER_PTRS 1
float32x4x4_t load_row(float *src, int64_t stride_xm, int64_t stride_xp) {
auto r = vld1q_f32((float *)((uint8_t*)src + stride_xm)), s = vld1q_f32((float *)((uint8_t*)src + stride_xp));
auto q = vld2q_f32(src); src += 8;
#if WRONG_CODE_LEADING_TO_FEWER_PTRS == 1
auto d0 = vextq_f32(q.val[0], q.val[1], 3), d1 = q.val[0];
auto d3 = vextq_f32(q.val[0], q.val[1], 1), d2 = q.val[1];
#else
auto d0 = vextq_f32(r, q.val[1], 3), d1 = q.val[0];
auto d3 = vextq_f32(q.val[0], s, 1), d2 = q.val[1];
#endif
return float32x4x4_t{d0,d1,d2,d3};
}
void conv(float *src0, float *src1, float *src2, float *src3,
float *dst, float *dst2, float *coeffs, int width) {
const int OC = 8;
const int IC = 16;
int64_t stride_xp = 8*IC*4;
int64_t stride_xn = -stride_xp;
do {
int oc = OC;
do {
auto zz = coeffs;
float32x4_t o000,o001,o002,o003;
float32x4_t o010,o011,o012,o013;
float32x4_t o100,o101,o102,o103;
float32x4_t o110,o111,o112,o113;
int ic = IC;
do {
auto c0 = vld1q_f32(zz); zz += 4;
auto data = load_row(src0, stride_xp, stride_xn); src0+=8;
auto c1 = vld1q_f32(zz); zz += 4;
o000 += c0[0] * data.val[0];
o001 += c0[1] * data.val[0];
o002 += c0[2] * data.val[0];
o003 += c0[3] * data.val[0];
o010 += c0[0] * data.val[1];
o011 += c0[1] * data.val[1];
o012 += c0[2] * data.val[1];
o013 += c0[3] * data.val[1];
auto c2 = vld1q_f32(zz); zz += 4;
o000 += c1[0] * data.val[1];
o001 += c1[1] * data.val[1];
o002 += c1[2] * data.val[1];
o003 += c1[3] * data.val[1];
o010 += c1[0] * data.val[2];
o011 += c1[1] * data.val[2];
o012 += c1[2] * data.val[2];
o013 += c1[3] * data.val[2];
o000 += c2[0] * data.val[2];
o001 += c2[1] * data.val[2];
o002 += c2[2] * data.val[2];
o003 += c2[3] * data.val[2];
o010 += c2[0] * data.val[3];
o011 += c2[1] * data.val[3];
o012 += c2[2] * data.val[3];
o013 += c2[3] * data.val[3];
data = load_row(src1, stride_xp, stride_xn);src1+=8;
o100 += c0[0] * data.val[0];
o101 += c0[1] * data.val[0];
o102 += c0[2] * data.val[0];
o103 += c0[3] * data.val[0];
o110 += c0[0] * data.val[1];
o111 += c0[1] * data.val[1];
o112 += c0[2] * data.val[1];
o113 += c0[3] * data.val[1];
c0 = vld1q_f32(zz);zz += 4;
o100 += c1[0] * data.val[1];
o101 += c1[1] * data.val[1];
o102 += c1[2] * data.val[1];
o103 += c1[3] * data.val[1];
o110 += c1[0] * data.val[2];
o111 += c1[1] * data.val[2];
o112 += c1[2] * data.val[2];
o113 += c1[3] * data.val[2];
c1 = vld1q_f32(zz);zz += 4;
o100 += c2[0] * data.val[2];
o101 += c2[1] * data.val[2];
o102 += c2[2] * data.val[2];
o103 += c2[3] * data.val[2];
o110 += c2[0] * data.val[3];
o111 += c2[1] * data.val[3];
o112 += c2[2] * data.val[3];
o113 += c2[3] * data.val[3];
c2 = vld1q_f32(zz);
zz += 4;
o000 += c0[0] * data.val[0];
o001 += c0[1] * data.val[0];
o002 += c0[2] * data.val[0];
o003 += c0[3] * data.val[0];
o010 += c0[0] * data.val[1];
o011 += c0[1] * data.val[1];
o012 += c0[2] * data.val[1];
o013 += c0[3] * data.val[1];
o000 += c1[0] * data.val[1];
o001 += c1[1] * data.val[1];
o002 += c1[2] * data.val[1];
o003 += c1[3] * data.val[1];
o010 += c1[0] * data.val[2];
o011 += c1[1] * data.val[2];
o012 += c1[2] * data.val[2];
o013 += c1[3] * data.val[2];
o000 += c2[0] * data.val[2];
o001 += c2[1] * data.val[2];
o002 += c2[2] * data.val[2];
o003 += c2[3] * data.val[2];
o010 += c2[0] * data.val[3];
o011 += c2[1] * data.val[3];
o012 += c2[2] * data.val[3];
o013 += c2[3] * data.val[3];
data = load_row(src2, stride_xp, stride_xn);src2+=8;
o100 += c0[0] * data.val[0];
o101 += c0[1] * data.val[0];
o102 += c0[2] * data.val[0];
o103 += c0[3] * data.val[0];
o110 += c0[0] * data.val[1];
o111 += c0[1] * data.val[1];
o112 += c0[2] * data.val[1];
o113 += c0[3] * data.val[1];
c0 = vld1q_f32(zz); zz += 4;
o100 += c1[0] * data.val[1];
o101 += c1[1] * data.val[1];
o102 += c1[2] * data.val[1];
o103 += c1[3] * data.val[1];
o110 += c1[0] * data.val[2];
o111 += c1[1] * data.val[2];
o112 += c1[2] * data.val[2];
o113 += c1[3] * data.val[2];
c1 = vld1q_f32(zz + 4); zz += 4;
o100 += c2[0] * data.val[2];
o101 += c2[1] * data.val[2];
o102 += c2[2] * data.val[2];
o103 += c2[3] * data.val[2];
o110 += c2[0] * data.val[3];
o111 += c2[1] * data.val[3];
o112 += c2[2] * data.val[3];
o113 += c2[3] * data.val[3];
c2 = vld1q_f32(zz + 4); zz += 4;
o000 += c0[0] * data.val[0];
o001 += c0[1] * data.val[0];
o002 += c0[2] * data.val[0];
o003 += c0[3] * data.val[0];
o010 += c0[0] * data.val[1];
o011 += c0[1] * data.val[1];
o012 += c0[2] * data.val[1];
o013 += c0[3] * data.val[1];
o000 += c1[0] * data.val[1];
o001 += c1[1] * data.val[1];
o002 += c1[2] * data.val[1];
o003 += c1[3] * data.val[1];
o010 += c1[0] * data.val[2];
o011 += c1[1] * data.val[2];
o012 += c1[2] * data.val[2];
o013 += c1[3] * data.val[2];
o000 += c2[0] * data.val[2];
o001 += c2[1] * data.val[2];
o002 += c2[2] * data.val[2];
o003 += c2[3] * data.val[2];
o010 += c2[0] * data.val[3];
o011 += c2[1] * data.val[3];
o012 += c2[2] * data.val[3];
o013 += c2[3] * data.val[3];
data = load_row(src3, stride_xp, stride_xn); src3+=8;
o100 += c0[0] * data.val[0];
o101 += c0[1] * data.val[0];
o102 += c0[2] * data.val[0];
o103 += c0[3] * data.val[0];
o110 += c0[0] * data.val[1];
o111 += c0[1] * data.val[1];
o112 += c0[2] * data.val[1];
o113 += c0[3] * data.val[1];
o100 += c1[0] * data.val[1];
o101 += c1[1] * data.val[1];
o102 += c1[2] * data.val[1];
o103 += c1[3] * data.val[1];
o110 += c1[0] * data.val[2];
o111 += c1[1] * data.val[2];
o112 += c1[2] * data.val[2];
o113 += c1[3] * data.val[2];
o100 += c2[0] * data.val[2];
o101 += c2[1] * data.val[2];
o102 += c2[2] * data.val[2];
o103 += c2[3] * data.val[2];
o110 += c2[0] * data.val[3];
o111 += c2[1] * data.val[3];
o112 += c2[2] * data.val[3];
o113 += c2[3] * data.val[3];
} while (--ic);
float32x4x2_t o0{o000, o010};
vst2q_f32(dst, o0);
dst += 8;
float32x4x2_t o1{o001, o011};
vst2q_f32(dst, o1);
dst += 8;
float32x4x2_t o2{o002, o012};
vst2q_f32(dst, o2);
dst += 8;
float32x4x2_t o3{o003, o013};
vst2q_f32(dst, o3);
dst += 8;
{
float32x4x2_t o0{o100, o110};
vst2q_f32(dst2, o0);
dst2 += 8;
float32x4x2_t o1{o101, o111};
vst2q_f32(dst2, o1);
dst2 += 8;
float32x4x2_t o2{o102, o112};
vst2q_f32(dst2, o2);
dst2 += 8;
float32x4x2_t o3{o103, o113};
vst2q_f32(dst2, o3);
dst2 += 8;
}
} while (--oc);
} while (--width);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztW11z4jgW_TXkRQXlK_OVBx7SSXonNTOdqd6u6n2jhC3AO7JFWzLQ-fV7JRmwAWPAXfsyTojBsnTu0dGVrm-wZjL8OXlLiF5yMpdCyE2ULEiHUpVEqxXX-IlsllGwJJEiUaJ5EvKQaEkCGa8yzQmWKJniabKWItORTBSRc6KiD05g-9v2e4c-jRHwiYy3Pv7CkGTK2DAWExatecd76XhPMddLGSKHlDAyEzL428DQLd32CdNYpqOYd-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