https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119374
Bug ID: 119374 Summary: armv7ve+neon-vfpv4: Miscompilation with -O2 Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: myokaski at gmail dot com Target Milestone: --- Created attachment 60823 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60823&action=edit testcase gcc -march=armv7ve+neon-vfpv4 -O2 ftest.c produces wrong result with GCC 14.2.0 and 12.2.0. 11.4.0 seems to be ok. Correct output: shift = 4 xx = 4096 xy = 0 yx = 0 yy = 4096 temp1 = 536870912 temp2 = 33554432 check = 1 Wrong output: shift = 4 xx = 65536 xy = 0 yx = 0 yy = 65536 temp1 = 0 temp2 = 0 check = 0 Works normally with -O0/-fno-tree-vectorize. The assembly output of this part: if ( shift > 0 ) // shift is 4 here: ( 31 - __builtin_clz( val ) ) - 12 { xx >>= shift; xy >>= shift; yx >>= shift; yy >>= shift; } is cmp r4, #0 ble .L2 vshl.i32 q4, q4, #0 // here nothing is done ... .L2 If shift is set to immediate by 'shift = 4;', asm is generated correctly: 'vshr.s32 q4, q4, #4' Correct result is also generated if I remove temp1/temp2-related code. Original code was FT_Matrix_Check function from freetype library sources.