Simplify abs (copysign (x, y))
The following adds simplification of abs (copysign (x, y)) to abs (x). * match.pd (abs (copysign (x, y)) -> abs (x)): New pattern. * gcc.dg/fold-abs-6.c: New testcase.
This commit is contained in:
parent
d326bb6d75
commit
f7d7e26f10
2 changed files with 14 additions and 0 deletions
|
@ -7445,6 +7445,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
|
|||
(COPYSIGN_ALL @0 tree_expr_nonnegative_p@1)
|
||||
(abs @0))
|
||||
|
||||
(simplify
|
||||
/* fabs (copysign(x, y)) -> fabs (x). */
|
||||
(abs (COPYSIGN_ALL @0 @1))
|
||||
(abs @0))
|
||||
|
||||
(for scale (LDEXP SCALBN SCALBLN)
|
||||
/* ldexp(0, x) -> 0. */
|
||||
(simplify
|
||||
|
|
9
gcc/testsuite/gcc.dg/fold-abs-6.c
Normal file
9
gcc/testsuite/gcc.dg/fold-abs-6.c
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -fdump-tree-original" } */
|
||||
|
||||
float foo (float x, float y)
|
||||
{
|
||||
return __builtin_fabsf (__builtin_copysignf (x, y));
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump "return ABS_EXPR <x>;" "original" } } */
|
Loading…
Add table
Reference in a new issue