https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113065
Bug ID: 113065 Summary: [ARM][NEON] Compiler crashes when doing shift on data with NEON intrinsic type Product: gcc Version: 11.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: clh960524+gcc at gmail dot com Target Milestone: --- Created attachment 56900 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56900&action=edit preprocessor result Hi developers, Currently I am working on adding ARMv8-A 32-bit test environment. However, compiler outputs an internal error when it tries to do shifting on NEON intrinsic data type. This bug is confirmed on arm-linux-gnueabihf-gcc version 10.5.0, 11.4.0, and 12.3.0. For your ease, here is the code to reproduce the issue (test.c): #include <stddef.h> #include <arm_neon.h> #include <arm_acle.h> #define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) #define SIMDE_POLY64_TYPE poly64_t #define SIMDE_POLY64_C(value) (HEDLEY_STATIC_CAST(poly64_t, value ## ull)) typedef SIMDE_POLY64_TYPE simde_poly64; typedef simde_poly64 simde_poly64_t; typedef poly128_t simde_poly128_t; simde_poly128_t simde_vaddq_p128(simde_poly128_t a, simde_poly128_t b) { simde_poly128_t mask = 0xFFFFFFFFFFFFFFFFull; mask = mask << 64; mask = mask | 0xFFFFFFFFFFFFFFFFull; return b ^ ((0 ^ a) & mask); } static int simde_assert_equal_p64(simde_poly64 a, simde_poly64 b) { uint64_t a_ = HEDLEY_STATIC_CAST(uint64_t, a); uint64_t b_ = HEDLEY_STATIC_CAST(uint64_t, b); if (a_ != b_) { return 1; } return 0; } static int test_simde_vaddq_p128 () { struct { simde_poly64_t a[2]; simde_poly64_t b[2]; simde_poly64_t r[2]; } test_vec[] = { { { SIMDE_POLY64_C( 2773134259082670592), SIMDE_POLY64_C( 9031857671464751104) }, { SIMDE_POLY64_C(15408611317451976704), SIMDE_POLY64_C( 5314471842361763840) }, { SIMDE_POLY64_C(17557921622677996032), SIMDE_POLY64_C( 3789586984176121856) } }, { { SIMDE_POLY64_C(14363410812027238400), SIMDE_POLY64_C( 7751777860661664768) }, { SIMDE_POLY64_C( 4070846577912177664), SIMDE_POLY64_C( 8033403141717473280) }, { SIMDE_POLY64_C(18386960794487266304), SIMDE_POLY64_C( 355706841938420736) } }, { { SIMDE_POLY64_C(17019201421568192512), SIMDE_POLY64_C( 9077731670917768192) }, { SIMDE_POLY64_C( 1093803490337685888), SIMDE_POLY64_C(12690135020377692160) }, { SIMDE_POLY64_C(16365414741193798016), SIMDE_POLY64_C(14836825620528675840) } }, { { SIMDE_POLY64_C( 8834005665657798656), SIMDE_POLY64_C( 7315692870291161088) }, { SIMDE_POLY64_C( 3583172236868845568), SIMDE_POLY64_C(14913079096527761408) }, { SIMDE_POLY64_C( 5413693383775240192), SIMDE_POLY64_C(12354334249137418240) } }, { { SIMDE_POLY64_C(16318651152855345152), SIMDE_POLY64_C(15283972988033570816) }, { SIMDE_POLY64_C( 4795255037585536000), SIMDE_POLY64_C(17815911970323484672) }, { SIMDE_POLY64_C(11599959615349332992), SIMDE_POLY64_C( 2532502929754736640) } }, { { SIMDE_POLY64_C(16540936757178476544), SIMDE_POLY64_C( 4596081763017794560) }, { SIMDE_POLY64_C(15120265319048798208), SIMDE_POLY64_C( 3251201193519464448) }, { SIMDE_POLY64_C( 3771992723781634048), SIMDE_POLY64_C( 1357279216665519104) } }, { { SIMDE_POLY64_C( 7991373722374909952), SIMDE_POLY64_C(17418001980645539840) }, { SIMDE_POLY64_C( 303154826827825408), SIMDE_POLY64_C( 9983013542091358208) }, { SIMDE_POLY64_C( 7697238601746657536), SIMDE_POLY64_C( 8877691528758722560) } }, { { SIMDE_POLY64_C(14668463690243614720), SIMDE_POLY64_C( 4370163632906065408) }, { SIMDE_POLY64_C( 3236423722687647744), SIMDE_POLY64_C( 6051015495717347328) }, { SIMDE_POLY64_C(16679868711160412160), SIMDE_POLY64_C( 8024418529387197952) } }, }; for (size_t i = 0 ; i < (sizeof(test_vec) / sizeof(test_vec[0])) ; i++) { simde_poly128_t a = test_vec[i].a[0]; simde_poly128_t b = test_vec[i].b[0]; simde_poly128_t r, mask; simde_poly64_t top_r, bottom_r; a = a << 64; a = a | test_vec[i].a[1]; b = b << 64; b = b | test_vec[i].b[1]; r = simde_vaddq_p128(a, b); mask = HEDLEY_STATIC_CAST(simde_poly128_t, 0xFFFFFFFFFFFFFFFFull); top_r = HEDLEY_STATIC_CAST(simde_poly64_t, (r >> 64) & mask); bottom_r = HEDLEY_STATIC_CAST(simde_poly64_t, (r << 64) >> 64); simde_assert_equal_p64(top_r, test_vec[i].r[0]); simde_assert_equal_p64(bottom_r, test_vec[i].r[1]); } return 0; } int main() { test_simde_vaddq_p128(); return 0; } Here's the command for compiling: arm-linux-gnueabihf-gcc -v -save-temps -mcpu=cortex-a32 -mfpu=crypto-neon-fp-armv8 -Wextra -Werror -Wall -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations test.c