This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Generalize -(-X) a little
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 2 Nov 2017 13:40:44 +0100
- Subject: Re: Generalize -(-X) a little
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.02.1711011139110.32319@stedding.saclay.inria.fr>
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