https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127149
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:7b2eb3f41bfb09afbd50cd42ac2ee6da5032f458 commit r15-11626-g7b2eb3f41bfb09afbd50cd42ac2ee6da5032f458 Author: Jakub Jelinek <[email protected]> Date: Wed Sep 2 11:27:11 2026 +0200 vect-patterns: Fix up vect_recog_popcount_clz_ctz_ffs_pattern for non-mode precision types [PR127149] The following testcase is miscompiled on aarch64-linux. The problem is that vect_recog_popcount_clz_ctz_ffs_pattern for builtins other than clz doesn't require type_has_mode_precision_p (lhs_type) and matches to an ifn with an argument with say _BitInt(7) type (as well as result) and we then happily vectorize it and match something that doesn't properly extend the padding bits. One possibility is to punt in this case (i.e. if (!type_has_mode_precision_p (lhs_type)) return NULL; ), the following patch instead pattern matches it with a cast to/from the TREE_TYPE (vec_type), i.e. the actual mode precision type we'll use for the vectorization. 2026-09-02 Jakub Jelinek <[email protected]> PR tree-optimization/127149 * tree-vect-patterns.cc (vect_recog_popcount_clz_ctz_ffs_pattern): Handle lhs_type without mode precision by adding casts. * gcc.dg/bitint-142.c: New test. Reviewed-by: Richard Biener <[email protected]> (cherry picked from commit 431068af077e13f0113f3640385b7b6cfa0a3e68)
