I try to analyse this code: ------------------------------------------------------ int foo (int N) { int ftab[257]; int i, j;
for (i = 0; i < N - 7488645; i++) j = ftab [i]; return j; } ------------------------------------------------------ The number of iterations I get is: (unsigned int) N_5(D) + 0x0ffffffff However I expect it to be (unsigned int) N_5(D) + (-1) At the moment we convert these values in Graphite using int_cst_value even if 0x0ffffffff does not fit in host_integerp(). In some cases we get free wrapping to -1 (that seems to be correct), however in others this hackish use of int_cst_value leads to incorrect code. Now I try to convert this value directly to a gmp value. Using this approach. ---------------------------------------------------------------------- double_int di = tree_to_double_int (t); mpz_set_double_int (res, di, TYPE_UNSIGNED (TREE_TYPE (t))); ---------------------------------------------------------------------- However the "di" value is again (2^32 -1) instead of -1, so the gmp value I get is not the -1 it actually should be. The conversion from tree to gmp value seems to be correct as double_int_negative_p (di) == false, as well as TYPE_UNSIGNED (TREE_TYPE (t)) == true Now the big question. Should it be represented as an signed int in the tree so that my conversion works or how can I detect that I have to simulate the wrapping? I suspect the conversion might happen here: (gdb) print t.int_cst.common.type.base $11 = {code = INTEGER_TYPE, side_effects_flag = 0, constant_flag = 0, addressable_flag = 0, volatile_flag = 0, readonly_flag = 0, unsigned_flag = 1, ...} (gdb) print t.type.common.base $12 = {code = INTEGER_CST, side_effects_flag = 0, constant_flag = 1, addressable_flag = 0, volatile_flag = 0, readonly_flag = 0, unsigned_flag = 0, ...} (gdb) print t.common.type.base $13 = {code = INTEGER_TYPE, side_effects_flag = 0, constant_flag = 0, addressable_flag = 0, volatile_flag = 0, readonly_flag = 0, unsigned_flag = 1, ...} What is the meaning of the different types. Some have the unsigned_flag set, others not? Thanks a lot Tobias