Created attachment 56526 [details] output of freport-bug We see a verify_ssa failed on 14. According to our testing on CI, this is a regression between snapshots 20231015 and 20231029. I haven't tested any version in between these. I have attached the source, but sorry, it's a huge unit build... Target: x86_64-pc-linux-gnu Configured with: ../gcc-14-20231105/configure --prefix=/opt/gcc-snapshot --enable-languages=c --disable-bootstrap --disable-multilib --without-isl Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20231105 (experimental) (GCC) In file included from src/scalar_impl.h:22, from src/secp256k1.c:28: src/scalar_8x32_impl.h: In function 'secp256k1_scalar_reduce_512': src/scalar_8x32_impl.h:417:13: error: missing definition 417 | static void secp256k1_scalar_reduce_512(secp256k1_scalar *r, const uint32_t *l) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ for SSA_NAME: c2_505 in statement: # DEBUG c2 => _110 + c2_505 during GIMPLE pass: widening_mul src/scalar_8x32_impl.h:417:13: internal compiler error: verify_ssa failed 0x1212c19 verify_ssa(bool, bool) ../../gcc-14-20231105/gcc/tree-ssa.cc:1203 0xe8c3c5 execute_function_todo ../../gcc-14-20231105/gcc/passes.cc:2095 0xe8c7ae execute_todo ../../gcc-14-20231105/gcc/passes.cc:2142 /opt/gcc-snapshot/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/cc1 -quiet -I . -imultiarch x86_64-linux-gnu -MD src/.libs/libsecp256k1_la-secp256k1.d -MF src/.deps/libsecp256k1_la-secp256k1.Tpo -MP -MT src/libsecp256k1_la-secp256k1.lo -D PACKAGE_NAME="libsecp256k1" -D PACKAGE_TARNAME="libsecp256k1" -D PACKAGE_VERSION="0.4.1-dev" -D PACKAGE_STRING="libsecp256k1 0.4.1-dev" -D PACKAGE_BUGREPORT="https://github.com/bitcoin-core/secp256k1/issues" -D PACKAGE_URL="https://github.com/bitcoin-core/secp256k1" -D PACKAGE="libsecp256k1" -D VERSION="0.4.1-dev" -D HAVE_STDIO_H=1 -D HAVE_STDLIB_H=1 -D HAVE_STRING_H=1 -D HAVE_INTTYPES_H=1 -D HAVE_STDINT_H=1 -D HAVE_STRINGS_H=1 -D HAVE_SYS_STAT_H=1 -D HAVE_SYS_TYPES_H=1 -D HAVE_UNISTD_H=1 -D STDC_HEADERS=1 -D HAVE_DLFCN_H=1 -D LT_OBJDIR=".libs/" -D USE_FORCE_WIDEMUL_INT64=1 -D ECMULT_WINDOW_SIZE=15 -D ECMULT_GEN_PREC_BITS=4 -D VALGRIND -D PIC src/secp256k1.c -quiet -dumpdir src/.libs/ -dumpbase libsecp256k1_la-secp256k1.c -dumpbase-ext .c -mtune=generic -march=x86-64 -g -O2 -O2 -Wpedantic -Wno-long-long -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef -Wno-overlength-strings -Wall -Wno-unused-function -Wextra -Wcast-align -Wcast-align=strict -std=c90 -fvisibility=hidden -freport-bug -fPIC -o - -frandom-seed=0 -fdump-noaddr
Reproduced. ``` $ gcc /tmp/foo.i -c -g -O2 In file included from src/scalar_impl.h:22, from src/secp256k1.c:28: src/scalar_8x32_impl.h: In function ‘secp256k1_scalar_reduce_512’: src/scalar_8x32_impl.h:417:13: error: missing definition for SSA_NAME: c2_505 in statement: # DEBUG c2 => _110 + c2_505 during GIMPLE pass: widening_mul src/scalar_8x32_impl.h:417:13: internal compiler error: verify_ssa failed 0x55cf1bcb23c1 verify_ssa(bool, bool) [clone .constprop.0] /usr/src/debug/sys-devel/gcc-14.0.0_pre20231105/gcc-14-20231105/gcc/tree-ssa.cc:1203 0x55cf1d1affbb execute_function_todo /usr/src/debug/sys-devel/gcc-14.0.0_pre20231105/gcc-14-20231105/gcc/passes.cc:2095 0x55cf1d1affbb do_per_function /usr/src/debug/sys-devel/gcc-14.0.0_pre20231105/gcc-14-20231105/gcc/passes.cc:1687 0x55cf1d1affbb execute_todo /usr/src/debug/sys-devel/gcc-14.0.0_pre20231105/gcc-14-20231105/gcc/passes.cc:2142 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. ```
Reduced: ``` int secp256k1_scalar_reduce_512_r_0_0, secp256k1_scalar_reduce_512_m6, secp256k1_scalar_reduce_512_m9, secp256k1_scalar_reduce_512_th, secp256k1_scalar_reduce_512_tl; unsigned int secp256k1_scalar_reduce_512_c0; void secp256k1_scalar_reduce_512() { unsigned int c1, c2 = c1 < secp256k1_scalar_reduce_512_th; int over = secp256k1_scalar_reduce_512_c0 < secp256k1_scalar_reduce_512_m9; c1 += over; c2 += c1 < over; secp256k1_scalar_reduce_512_c0 = c1; c1 = c2; c2 = secp256k1_scalar_reduce_512_c0 += secp256k1_scalar_reduce_512_m6; over = secp256k1_scalar_reduce_512_c0 < secp256k1_scalar_reduce_512_m6; c1 += over; secp256k1_scalar_reduce_512_th += secp256k1_scalar_reduce_512_c0 < secp256k1_scalar_reduce_512_tl; c1 += secp256k1_scalar_reduce_512_th; c2 += c1 < secp256k1_scalar_reduce_512_th; secp256k1_scalar_reduce_512_r_0_0 = c2; } void secp256k1_ecdsa_sig_sign() { secp256k1_scalar_reduce_512(); } ```
Better reduction without uninit: ``` int secp256k1_scalar_reduce_512_r_0_0, secp256k1_scalar_reduce_512_m6, secp256k1_scalar_reduce_512_m9, secp256k1_scalar_reduce_512_th, secp256k1_scalar_reduce_512_tl; unsigned int secp256k1_scalar_reduce_512_c0; void secp256k1_scalar_reduce_512(unsigned int c1) { unsigned int c2 = c1 < secp256k1_scalar_reduce_512_th; int over = secp256k1_scalar_reduce_512_c0 < secp256k1_scalar_reduce_512_m9; c1 += over; c2 += c1 < over; secp256k1_scalar_reduce_512_c0 = c1; c1 = c2; c2 = secp256k1_scalar_reduce_512_c0 += secp256k1_scalar_reduce_512_m6; over = secp256k1_scalar_reduce_512_c0 < secp256k1_scalar_reduce_512_m6; c1 += over; secp256k1_scalar_reduce_512_th += secp256k1_scalar_reduce_512_c0 < secp256k1_scalar_reduce_512_tl; c1 += secp256k1_scalar_reduce_512_th; c2 += c1 < secp256k1_scalar_reduce_512_th; secp256k1_scalar_reduce_512_r_0_0 = c2; } void secp256k1_ecdsa_sig_sign(unsigned int c1) { secp256k1_scalar_reduce_512(c1); } ```
I knew this looked familiar... PR111845.
Bisected to r14-1837-g43a3252c42af12, same as the other PR.
Created attachment 56529 [details] Cleanup testcase Basically removed the long variable/function names.
Created attachment 56552 [details] gcc14-pr112430.patch Untested fix.
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:7610e5cc82bd6316cfe0bfee6d9f12d8c2cfa9c3 commit r14-5366-g7610e5cc82bd6316cfe0bfee6d9f12d8c2cfa9c3 Author: Jakub Jelinek <jakub@redhat.com> Date: Sat Nov 11 20:15:53 2023 +0100 tree-ssa-math-opts: Fix up gsi_remove order in match_uaddc_usubc [PR112430] The following testcase ICEs, because the temp_stmts were removed in wrong order, from the ones appearing earlier in the IL to the later ones, so insert_debug_temps_for_defs can reintroduce dead SSA_NAMEs back into the IL. The following patch fixes that by removing them in the order they were pushed into the vector, which is from later ones to earlier ones. Additionally, I've noticed I forgot to call release_defs on the removed stmts. 2023-11-11 Jakub Jelinek <jakub@redhat.com> PR middle-end/112430 * tree-ssa-math-opts.cc (match_uaddc_usubc): Remove temp_stmts in the order they were pushed rather than in reverse order. Call release_defs after gsi_remove. * gcc.dg/pr112430.c: New test.
Should be fixed now.