aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-pass.h
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-06-30 18:21:15 -0700
committerAndrew Pinski <quic_apinski@quicinc.com>2024-07-02 14:38:13 -0700
commita17ce10c97fa1d08c8d40507b6cf05642b5821fb (patch)
treea79be617dfe6ccbff3ce06609d54df9c24f96da0 /gcc/tree-pass.h
parentd8fe4f05ef448e6a136398d38c0f2170d3c6bb0d (diff)
downloadgcc-a17ce10c97fa1d08c8d40507b6cf05642b5821fb.zip
gcc-a17ce10c97fa1d08c8d40507b6cf05642b5821fb.tar.gz
gcc-a17ce10c97fa1d08c8d40507b6cf05642b5821fb.tar.bz2
Add some optimizations to gimple_expand_builtin_cabs
While looking into the original folding code for cabs (moved to match in r6-4111-gabcc43f5323869), I noticed that `cabs(x+0i)` was optimized even without the need of sqrt. I also noticed that now the code generation in this case will be worse if the target had a sqrt. So let's implement this small optimizations in gimple_expand_builtin_cabs. Note `cabs(x+0i)` is done without unsafe math optimizations. This is because the definition of `cabs(x+0i)` is `hypot(x, 0)` and the definition in the standard says that just returns `abs(x)`. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-complex.cc (gimple_expand_builtin_cabs): Add `cabs(a+ai)`, `cabs(x+0i)` and `cabs(0+xi)` optimizations. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/cabs-3.c: New test. * gcc.dg/tree-ssa/cabs-4.c: New test. * gcc.dg/tree-ssa/cabs-5.c: New test. * gcc.dg/tree-ssa/cabs-6.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc/tree-pass.h')
0 files changed, 0 insertions, 0 deletions