https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105431
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I can't reproduce in my dev tree but I guess the following will fix it?
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 7555793948e..f3efd1ef4b2 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -1495,7 +1495,7 @@ powi_cost (HOST_WIDE_INT n)
static tree
powi_as_mults_1 (gimple_stmt_iterator *gsi, location_t loc, tree type,
- HOST_WIDE_INT n, tree *cache)
+ unsigned HOST_WIDE_INT n, tree *cache)
{
tree op0, op1, ssa_target;
unsigned HOST_WIDE_INT digit;
@@ -1548,7 +1548,7 @@ powi_as_mults (gimple_stmt_iterator *gsi, location_t loc,
memset (cache, 0, sizeof (cache));
cache[1] = arg0;
- result = powi_as_mults_1 (gsi, loc, type, (n < 0) ? -n : n, cache);
+ result = powi_as_mults_1 (gsi, loc, type, absu_hwi (n), cache);
if (n >= 0)
return result;