-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i686 gcc 12: regression at -O1 or -O2 #981
Comments
To reproduce
Confirmed with https://github.com/simd-everywhere/simde/releases/tag/v0.7.4-rc3 |
Will probably be helped by #1025 |
I'll investigate. It is very much possible that this is due to MMX. |
Ok, this is not related to MMX. Doing some tests, it seems that this is a GCC bug specific to GCC 12 that has been fixed in GCC 12.2.1. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106322 Baaasically, it seems that there was an incorrect guard for whether the # x86_64 -mno-mmx -mno-sse (artificial)
mulhi_pu16:
mov rax, rsi
mul rdi
mov rax, rdx
ret
# i686 -mno-mmx -mno-sse
mulhi_pu16:
push ebx
mov eax, DWORD PTR [esp+12]
mul DWORD PTR [esp+20]
mov eax, DWORD PTR [esp+16]
mov ecx, DWORD PTR [esp+8]
mov ebx, edx
mul DWORD PTR [esp+24]
mov eax, ecx
mov DWORD PTR [ecx], ebx
mov DWORD PTR [ecx+4], edx
pop ebx
ret 4
# arm -mfloat-abi=soft
mulhi_pu16:
ldrd ip, r1, [sp]
umull ip, r2, ip, r2
umull r1, r3, r1, r3
strd r2, r3, [r0]
bx lr It seems that we just need to break up the autovec pattern, which amusingly is as simple as a backwards loop |
@easyaspi314 thanks for the research! Can you be more specific as to how we can workaround this for those using the affected versions of GCC? |
Ah, I'll try |
attribute optimize does work temporarily but it does disable inlining which emits a warn/error. /* GCC 12.1-12.2.0 emit garbage if vector.umulh is not
* a legal operation. Looping backwards breaks the
* vectorization pattern. */
#if defined(SIMDE_GCC_BUG_106322)
for (int i = num; i-- > 0; ) {
#else
for (int i = 0; i < num; i++) {
#endif should in theory work but I haven't tested thoroughly |
Hmm. Neither reversing the loop nor using
|
That backwards loop is off by one. |
The text was updated successfully, but these errors were encountered: