This patch implements transformations for the following optimizations.

logN(x) CMP CST -> x CMP expN(CST)
expN(x) CMP CST -> x CMP logN(CST)

For example:

int
foo (float x)
{
  return __builtin_logf (x) < 0.0f;
}

can just be:

int
foo (float x)
{
  return x < 1.0f;
} 

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Soumya AR <soum...@nvidia.com>

gcc/ChangeLog:

        * match.pd: Fold logN(x) CMP CST -> x CMP expN(CST)
        and expN(x) CMP CST -> x CMP logN(CST)

gcc/testsuite/ChangeLog:

        * gcc.dg/tree-ssa/log_exp.c: New test.

Attachment: 0001-Match-Optimize-log-x-CMP-CST-and-exp-x-CMP-CST-opera.patch
Description: 0001-Match-Optimize-log-x-CMP-CST-and-exp-x-CMP-CST-opera.patch

Reply via email to