On Thu, Oct 18, 2012 at 6:21 PM, Marek Polacek <pola...@redhat.com> wrote: > This patch changes folding in fold_sign_changed_comparison in a way > that when we have pointer/non-pointer comparison, we give up folding > here. The issue is e.g. when we have (intptr_t) &MEM[(void *)&x + 4B] > == (intptr_t) &y and forwprop wants to fold this one via > fold_binary_loc--we then end up folding non-sign-changing comparison. > > I don't know about the testcase though. I had something, but I think > it is too unrealiable. Regtested/bootstrapped on > x86_64-unknown-linux-gnu. Ok for trunk?
Ok for all active branches. Thanks, Richard. > 2012-10-18 Marek Polacek <pola...@redhat.com> > > * fold-const.c (fold_sign_changed_comparison): Punt if folding > pointer/non-pointer comparison. > > --- gcc/fold-const.c.mp 2012-10-17 15:01:34.882926243 +0200 > +++ gcc/fold-const.c 2012-10-18 18:02:55.482642941 +0200 > @@ -6731,12 +6731,14 @@ fold_sign_changed_comparison (location_t > && TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type)) > return NULL_TREE; > > - if ((TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type) > - || POINTER_TYPE_P (inner_type) != POINTER_TYPE_P (outer_type)) > + if (TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type) > && code != NE_EXPR > && code != EQ_EXPR) > return NULL_TREE; > > + if (POINTER_TYPE_P (inner_type) != POINTER_TYPE_P (outer_type)) > + return NULL_TREE; > + > if (TREE_CODE (arg1) == INTEGER_CST) > arg1 = force_fit_type_double (inner_type, tree_to_double_int (arg1), > 0, TREE_OVERFLOW (arg1)); > > Marek