]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/builtins.c
Move cabs simplifications to match.pd
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Oct 2015 20:19:25 +0000 (20:19 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Oct 2015 20:19:25 +0000 (20:19 +0000)
commitd064d9763ee7b40b8f5c464f1dc3246bac4eb273
tree6b28454ef437717184e8a12849ad52ead35988df
parent4616363b322bb76a47cb9c46491c8297884a2ec4
Move cabs simplifications to match.pd

The fold code also expanded cabs(x+yi) to fsqrt(x*x+y*y) when optimising
for speed.  tree-ssa-math-opts.c has this transformation too, but unlike
the fold code, it first checks whether the target implements the sqrt
optab.  The patch simply removes the fold code and keeps the
tree-ssa-math-opts.c logic the same.

gcc.dg/lto/20110201-1_0.c was relying on us replacing cabs
with fsqrt even on targets where fsqrt is itself a library call.
The discussion leading up to that patch suggested that we only
want to test the fold on targets with a square root instruction,
so it would be OK to skip the test on other targets:

        https://gcc.gnu.org/ml/gcc-patches/2011-07/msg01961.html
        https://gcc.gnu.org/ml/gcc-patches/2011-07/msg02036.html

The patch does that using the sqrt_insn effective target.

It's possible that removing the tree folds renders the LTO trick
unnecessary, but since the test was originally for an ICE, it seems
better to leave it as-is.

Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi.
20110201-1_0.c passes on all three.

gcc/
* builtins.c (fold_builtin_cabs): Delete.
(fold_builtin_1): Update accordingly.  Handle constant arguments here.
* match.pd: Add rules previously handled by fold_builtin_cabs.

gcc/testsuite/
* gcc.dg/lto/20110201-1_0.c: Restrict to sqrt_insn targets.
Add associated options for arm*-*-*.
(sqrt): Remove dummy definition.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229141 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/builtins.c
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/lto/20110201-1_0.c