Skip to content
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

gcc-14 bug compiling test/arm/neon/ext.cpp on x86 #1250

Open
Blarse opened this issue Dec 19, 2024 · 4 comments
Open

gcc-14 bug compiling test/arm/neon/ext.cpp on x86 #1250

Blarse opened this issue Dec 19, 2024 · 4 comments

Comments

@Blarse
Copy link

Blarse commented Dec 19, 2024

When compiling simde with gcc 14.2.1 on i586 I get the following error:

[1561/4004] Compiling C++ object test/arm/neon/ext-emul-cpp.p/meson-generated_.._ext.cpp.o
FAILED: test/arm/neon/ext-emul-cpp.p/meson-generated_.._ext.cpp.o 
c++ -Itest/arm/neon/ext-emul-cpp.p -Itest/arm/neon -I../test/arm/neon -I. -I.. -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O2 -g -pipe -frecord-gcc-switches -Wall -g -O2 -flto=auto -march=i586 -mtune=generic -fopenmp-simd -DSIMDE_CONSTRAINED_COMPILATION -DSIMDE_ENABLE_OPENMP -Wno-psabi -DSIMDE_TEST_BARE -DSIMDE_NO_NATIVE -ffloat-store -MD -MQ test/arm/neon/ext-emul-cpp.p/meson-generated_.._ext.cpp.o -MF test/arm/neon/ext-emul-cpp.p/meson-generated_.._ext.cpp.o.d -o test/arm/neon/ext-emul-cpp.p/meson-generated_.._ext.cpp.o -c test/arm/neon/ext.cpp
during GIMPLE pass: local-fnsummary
In file included from test/arm/neon/ext.cpp:2235:
../test/arm/neon/test-neon-footer.h: In function ‘simde_vext_p64’:
../test/arm/neon/test-neon-footer.h:17:3: internal compiler error: in predicate_for_phi_result, at ipa-fnsummary.cc:2447
   17 |   }
      |   ^
0x8fcfced internal_error(char const*, ...)
	???:0
0x8fcfdc2 fancy_abort(char const*, int, char const*)
	???:0
0x92f057c compute_fn_summary(cgraph_node*, bool)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.

The bug occurs only with -O2 or -O3 in function simde_vext_p64 specifically in simde/arm/neon/ext.h:967, when assigning destination vector values:

r_.values[i] = (src < (sizeof(r_.values) / sizeof(r_.values[0]))) ? a_.values[src] : b_.values[src & 0];

Simply reversing the condition fixes the issue:

r_.values[i] = (src >= (sizeof(r_.values) / sizeof(r_.values[0]))) ? b_.values[src & 0] : a_.values[src];
@mr-c
Copy link
Collaborator

mr-c commented Dec 19, 2024

Thank you @Blarse for the report. Did you file an issue in the GCC bug tracker?

@Blarse
Copy link
Author

Blarse commented Dec 21, 2024

Thank you @Blarse for the report. Did you file an issue in the GCC bug tracker?

Not yet actually, as I found this with our ALT Linux gcc ("i586-alt-linux-gcc (GCC) 14.2.1 20241028 (ALT Sisyphus 14.2.1-alt1)") and still wasn't able to test if this bug occurs on other systems. If you have an i586 system with gcc-14 at hand, I would appreciate it if you could confirm this error.

I'm also trying to create a small and independent from simde reproducer.

If you think it's better to report this right now without additional analysis, then I'll do it.

@Blarse
Copy link
Author

Blarse commented Dec 22, 2024

I've written a minimal reproducer.
Also I was able to reproduce this bug in debian experimental container with gcc (Debian 14.2.0-11) 14.2.0

#include "stdint.h"
#include "stddef.h"

typedef uint64_t poly64x1 __attribute__((__vector_size__(8)));

poly64x1 vext_p64(poly64x1 a, poly64x1 b, const int n)
{
  poly64x1 r = a;
  size_t src = ((size_t) (n));
  r[0] = (src < 1) ? a[src] : b[0];
  return r;
}
$ gcc -O2 -c ./reproducer.c 
during GIMPLE pass: local-fnsummary
./reproducer.c: In function 'vext_p64':
./reproducer.c:12:1: internal compiler error: in predicate_for_phi_result, at ipa-fnsummary.cc:2447
   12 | }
      | ^
0x9133008 internal_error(char const*, ...)
	???:0
0x91330d2 fancy_abort(char const*, int, char const*)
	???:0
0x9291277 compute_fn_summary(cgraph_node*, bool)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
$ gcc -O1 -c ./reproducer.c 
during GIMPLE pass: uncprop
./reproducer.c: In function 'vext_p64':
./reproducer.c:6:10: internal compiler error: in promote_ssa_mode, at explow.cc:923
    6 | poly64x1 vext_p64(poly64x1 a, poly64x1 b, const int n)
      |          ^~~~~~~~
0x9133008 internal_error(char const*, ...)
	???:0
0x91330d2 fancy_abort(char const*, int, char const*)
	???:0
0x93bf7d9 gimple_can_coalesce_p(tree_node*, tree_node*)
	???:0
0x944fe9d uncprop_dom_walker::before_dom_children(basic_block_def*)
	???:0
0x958ed71 dom_walker::walk(basic_block_def*)
	???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.

Now I will create an issue in the GCC bug tracker.

@mr-c
Copy link
Collaborator

mr-c commented Dec 22, 2024

That's great, thank you @Blarse . We can add the GCC bug number to https://github.com/simd-everywhere/simde/wiki/Compiler-Bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants