]> git.ipfire.org Git - thirdparty/gcc.git/commit
Only allow (copysign x, NEG_CONST) -> (fneg (fabs x)) simplification for constant...
authorAndrew Pinski <pinskia@gmail.com>
Mon, 13 Nov 2023 20:18:34 +0000 (20:18 +0000)
committerXi Ruoyao <xry111@xry111.site>
Thu, 16 Nov 2023 23:45:33 +0000 (07:45 +0800)
commit9e9279fadbd1c673c875b9d20261d2de0473f63f
tree8522ab7692eff49ca3544c4fc36a102f2c6ccac3
parent1c1ee8097c3d96c74107a317f68b0ad40cf9207b
Only allow (copysign x, NEG_CONST) -> (fneg (fabs x)) simplification for constant folding [PR112483]

On targets with native copysign instructions, (copysign x, -1) is
usually more efficient than (fneg (fabs x)).  Since r14-5284, in the
middle end we always optimize (fneg (fabs x)) to (copysign x, -1), not
vice versa.  If the target does not support native fcopysign,
expand_COPYSIGN will expand it as (fneg (fabs x)) anyway.

gcc/ChangeLog:

PR rtl-optimization/112483
* simplify-rtx.cc (simplify_binary_operation_1) <case COPYSIGN>:
Call simplify_unary_operation for NEG instead of
simplify_gen_unary.
gcc/simplify-rtx.cc