Hi, Jeff told me that the recent popcount built-in detection is causing kernel build issues as ERROR: "__popcountsi2" [drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko] undefined!
I could also reproduce this. AFIK, we should check if the libfunc is defined while checking popcount? I am testing the attached RFC patch. Is this reasonable? Thanks, Kugan gcc/ChangeLog: 2018-07-10 Kugan Vivekanandarajah <kug...@linaro.org> * tree-ssa-loop-niter.c (number_of_iterations_popcount): Check if libfunc for popcount is available.
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index f6fa2f7..2e2b9c6 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "backend.h" +#include "target.h" #include "rtl.h" #include "tree.h" #include "gimple.h" @@ -42,6 +43,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-chrec.h" #include "tree-scalar-evolution.h" #include "params.h" +#include "optabs-libfuncs.h" #include "tree-dfa.h" @@ -2570,6 +2572,10 @@ number_of_iterations_popcount (loop_p loop, edge exit, (long_long_integer_type_node)) fn = builtin_decl_implicit (BUILT_IN_POPCOUNTLL); + /* Check if libfunc for popcount is available. */ + if (!optab_libfunc (popcount_optab, + TYPE_MODE (TREE_TYPE (src)))) + return false; /* ??? Support promoting char/short to int. */ if (!fn) return false;