This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Generalize -(-X) a little


On Fri, Nov 3, 2017 at 2:06 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Thu, 2 Nov 2017, Richard Biener wrote:
>
>> You can handle floats as followup but some testcases that shouldn't be
>> optimized for the INT_MIN / unsigned case would be nice.
>
>
> New version, that does a bit more.

-    case NEGATE_EXPR:
-      if (!TYPE_OVERFLOW_SANITIZED (type))
-       return TREE_OPERAND (t, 0);
-      break;
-
...
-  return NULL_TREE;
+  return generic_simplify (loc, NEGATE_EXPR, type, t);
 }

this will do redundant work when called from fold_unary for example.
Please leave fold-const.c as-is for now.

Ok with that change.

Thanks,
Richard.


> Bootstrap+regtest on powerpc64le-unknown-linux-gnu.
>
> 2017-11-03  Marc Glisse  <marc.glisse@inria.fr>
>
> gcc/
>         * fold-const.c (fold_negate_expr_1): Call generic_simplify. Remove
>         NEGATE_EXPR handling.
>         * match.pd (-(-A)): Rewrite.
>
> gcc/testsuite/
>         * gcc.dg/tree-ssa/negneg-1.c: New file.
>         * gcc.dg/tree-ssa/negneg-2.c: Likewise.
>         * gcc.dg/tree-ssa/negneg-3.c: Likewise.
>         * gcc.dg/tree-ssa/negneg-4.c: Likewise.
>
>
> --
> Marc Glisse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]