[Bug tree-optimization/107591] range-op{,-float}.cc for x * x

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 9 16:31:15 GMT 2022


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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
To answer my own question:
int
foo (int x)
{
  return x + x;
}

int
bar (int x)
{
  return x * x * x * x * x * x;
}

float
baz (float x)
{
  return x + x;
}

float
qux (float x)
{
  return x * x * x * x * x * x;
}

float
corge (float x)
{
  return x * x;
}
match.pd or fold-const.cc canonicalizes x + x to x * 2, so no need to special
case that, x * x isn't canonicalized for integral types nor without -ffast-math
for floats either, with -ffast-math reassoc1 canonicalizes the multiplications
into __builtin_powif (x, 6) resp. __builtin_powif (x, 2) until powcabs pass
later on splits those into multiplications again.
So, for frange, if we implement good range op for CASE_CFN_POWI, we could just
use that, perhaps for VREL_EQ on mult.


More information about the Gcc-bugs mailing list