https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118689
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, there are two issues. With r15-7223 niters analysis can finally determine
there is a clz/ctz-ish loop. But the m2 FE doesn't build
__builtin_c[lt]z{,l,ll} builtins, so
fn is NULL and build_cltz_expr assumes that it will be always non-NULL.
Here is a fix for the ICE on the build_cltz_expr side.
And m2 FE should be extended to provide those builtins.
2025-01-30 Jakub Jelinek <[email protected]>
PR tree-optimization/118689
* tree-ssa-loop-niter.cc (build_cltz_expr): Return NULL_TREE if fn is
NULL and use_ifn is false.
--- gcc/tree-ssa-loop-niter.cc.jj 2025-01-17 11:29:34.080683133 +0100
+++ gcc/tree-ssa-loop-niter.cc 2025-01-30 14:51:57.528933620 +0100
@@ -2238,6 +2238,8 @@ build_cltz_expr (tree src, bool leading,
build_int_cst (integer_type_node, prec));
}
}
+ else if (fn == NULL_TREE)
+ return NULL_TREE;
else if (prec == 2 * lli_prec)
{
tree src1 = fold_convert (long_long_unsigned_type_node,
The reason this doesn't ICE on e.g. x86_64 or aarch64 is that we just use ifn
there because
direct_internal_fn_supported_p (ifn, utype, OPTIMIZE_FOR_BOTH)
is true.