[Bug tree-optimization/105368] [10/11/12 Regression] ICE: SIGSEGV in powi_lookup_cost (tree-ssa-math-opts.cc:1441) with -Ofast and __builtin_powf()

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 25 08:54:58 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105368

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-04-25
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Zdenek Sojka from comment #3)
> I think the issue might be in the:
> 
> > 1463    
> > 1464      /* Ignore the reciprocal when calculating the cost.  */
> > 1465      val = (n < 0) ? -n : n;
> 
> expression, for the case n == LONG_MIN, but I am not a language lawyer. (-n
> is not representable in the (promoted) signed type)

Ah, good point.

diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 102b7a2cc99..7555793948e 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -1462,7 +1462,7 @@ powi_cost (HOST_WIDE_INT n)
     return 0;

   /* Ignore the reciprocal when calculating the cost.  */
-  val = (n < 0) ? -n : n;
+  val = absu_hwi (n);

   /* Initialize the exponent cache.  */
   memset (cache, 0, POWI_TABLE_SIZE * sizeof (bool));


should fix that.


More information about the Gcc-bugs mailing list