]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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)
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

index 2d2e5a3c1ca67e279239e15aff0f1fb954e01f40..f3745d86aeaa6669ee23b00cb795a92baa06b0b4 100644 (file)
@@ -4392,7 +4392,7 @@ simplify_ashift:
          real_convert (&f1, mode, CONST_DOUBLE_REAL_VALUE (trueop1));
          rtx tmp = simplify_gen_unary (ABS, mode, op0, mode);
          if (REAL_VALUE_NEGATIVE (f1))
-           tmp = simplify_gen_unary (NEG, mode, tmp, mode);
+           tmp = simplify_unary_operation (NEG, mode, tmp, mode);
          return tmp;
        }
       if (GET_CODE (op0) == NEG || GET_CODE (op0) == ABS)