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 Wed, Nov 1, 2017 at 12:47 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> Hello,
>
> just a little tweak to that transformation. There is some overlap between
> the 2 versions, but it seemed easier to handle the NOP case (including the
> case without convert and the vector case) separately from the narrowing /
> sign-extending scalar integer case.
>
> At some point it would be good to have fold_negate_expr call
> generic_simplify so we could remove some transformations from fold-const.c.
>
> Bootstrap+regtest on powerpc64le-unknown-linux-gnu.

+  (negate (convert (negate @1)))
+  (if (INTEGRAL_TYPE_P (type)
+       && (TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@1))
+          || (!TYPE_UNSIGNED (TREE_TYPE (@1))
+              && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@1))))
+       && !TYPE_OVERFLOW_SANITIZED (type)
+       && !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@1)))

so I don't understand this fully -- a widening conversion is ok only for
signed types with undefined overflow?  How does overflow come into play
here at all?

The testcase doesn't tell ...

For floats eliding any conversion should be ok if not flag_rounding_math
and flag_unsafe_math_optimizations (we remove a rounding step)?

Richard.

> 2017-11-01  Marc Glisse  <marc.glisse@inria.fr>
>
> gcc/
>         * match.pd (-(-A)): Rewrite.
>
> gcc/testsuite/
>         * gcc.dg/negneg.c: New file.
>
> --
> Marc Glisse


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