Internal compiler error gen_llvm_expr(): unkown opcode, when trying to compile FLINT using nvc

Hi,

we’re trying to build the FLINT library (Number Theory) using nvc and are encountering an internal compiler error when compiling:

[…]
CC …/build/fmpz_factor/fmpz_factor_ecm_select_curve.o
CC …/build/fmpz_factor/fmpz_factor_ecm_stage_I.o
NVC+±F-0000-Internal compiler error. gen_llvm_expr(): unknown opcode 0 (ecm.c: 151)
NVC++/x86-64 Linux 22.5-0: compilation aborted
make[2]: *** […/Makefile.subdirs:75: …/build/fmpz_factor/fmpz_factor_ecm.o] Error 2

We checked the file in question (ecm.c), but couldn’t find any problematic code.
Does anyone have some advice on how to fix this problem?

Here’s our build.sh, so you can reproduce the problem.
build.sh (163 Bytes)

Thank you,
Timo

Thanks Timo.

I was able to reproduce the error and have filed a problem report, TPR #32356.

Unfortunately, I’m not able to find a good work around, but the error is coming from the ASM statement in the “count_leading_zeros” macro at line 79 of ecm.c. Looks to be a problem with using a function (fmpz_get_ui) returning a struct (mp_limb_t) being used in the ASM statement.

I can work around in a small reproducer I extracted, but causes other issues when used in the full code:

 % cat test.c

#include "gmp.h"

#define ulong mp_limb_t
#define slong mp_limb_signed_t

typedef slong fmpz;
typedef fmpz fmpz_t[1];
ulong fmpz_get_ui(const fmpz_t f);

void foo(const fmpz_t n_in) {
mp_limb_t __cbtmp, tmp;
tmp = fmpz_get_ui(n_in);
#ifdef WORKS
__asm__ ("bsrq %1,%0" : "=r" (__cbtmp) : "rm" ((mp_limb_t)(tmp)));
#else
__asm__ ("bsrq %1,%0" : "=r" (__cbtmp) : "rm" ((mp_limb_t)(fmpz_get_ui(n_in))));
#endif
}

% nvc -c test.c -I. -w -DWORKS
% nvc -c test.c -I. -w 
NVC++-F-0000-Internal compiler error. gen_llvm_expr(): unknown opcode       0  (test.c: 19)
NVC++/x86-64 Linux 22.7-0: compilation aborted

-Mat