[PATCH] Sign extend before converting constants to GMP values.

Sebastian Pop sebpop@gmail.com
Thu Jun 30 14:48:00 GMT 2011


On Thu, Jun 30, 2011 at 05:19, Richard Guenther <rguenther@suse.de> wrote:
> That looks odd.  So you given -1U as input you sign-extend that to -1

correct

> and then set the mpz to -1ULLL.

and then it sets the mpz to signed -1, given that I'm passing false to UNS:

/* Sets RESULT to VAL, taken unsigned if UNS is true and as signed
   otherwise.  */

void
mpz_set_double_int (mpz_t result, double_int val, bool uns)

> In fact it looks like you either
> have non-canoncial INTEGER_CSTs from the start or the type of the
> integer constants is wrong.

I don't know what a canonical INTEGER_CST is.

Here are the cases that can occur:
- translating to mpz a -1U as the upper bound of an unsigned type,
in which case I do not want it to be sign extended,
- translating to mpz a -1U constant in an unsigned expression "x + -1U"
in which I do want it to be sign extended.

In my opinion there is not enough information to decide whether
to sign extend or not the value in tree_int_to_gmp.

Sebastian



More information about the Gcc-patches mailing list