------- Comment #12 from law at redhat dot com 2006-06-08 16:38 ------- Subject: Re: bootstrap failure building libdecnumber, ICE in compare_values, tree-vrp.c:432
On Thu, 2006-06-08 at 09:47 +0000, rguenth at gcc dot gnu dot org wrote: > > ------- Comment #11 from rguenth at gcc dot gnu dot org 2006-06-08 09:47 > ------- > This one: > > /* Apply the operation to each end of the range and see what we end > up with. */ > if (code == NEGATE_EXPR > && !TYPE_UNSIGNED (TREE_TYPE (expr))) > { > /* NEGATE_EXPR flips the range around. */ > min = (vr0.max == TYPE_MAX_VALUE (TREE_TYPE (expr)) && !flag_wrapv) > ? TYPE_MIN_VALUE (TREE_TYPE (expr)) > : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.max); > > max = (vr0.min == TYPE_MIN_VALUE (TREE_TYPE (expr)) && !flag_wrapv) > ? TYPE_MAX_VALUE (TREE_TYPE (expr)) > : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.min); > > } > > is wrong for > > (gdb) print vr0 > $3 = {type = VR_ANTI_RANGE, min = 0xb7d2b3a8, max = 0xb7d2b3a8, > equiv = 0x896c298} > (gdb) call debug_generic_expr (vr0.min) > -2147483648 > (gdb) call debug_generic_expr (vr0.max) > -2147483648 > > It needs to read: > > min = (vr0.max == TYPE_MIN_VALUE (TREE_TYPE (expr)) && !flag_wrapv) > ? TYPE_MAX_VALUE (TREE_TYPE (expr)) > : fold_unary_to_constant (code, TREE_TYPE (expr), vr0.max); > > values other than TYPE_MIN_VALUE are not special with inversion. I'm not terribly familiar with the code in question or this PR. But it seems to me that negating a signed type's minimum value should give you the same value with an overflow. ie, for a 32bit signed type - (-2147483648) => -2147483648 If I read your proposed change, you'd instead return the type's max value, in this case 2147483647. Which seems rather wrong. Diego is far more familiar with code than I am. jeff -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26998