Hi, On Thu, 28 Jun 2007, [EMAIL PROTECTED] wrote:
> Roman Zippel <[EMAIL PROTECTED]> wrote on 06/28/2007 07:54:43 PM: > > > Hi, > > Notice that it generates the (i + 1) * 4 instead of (i * 4) + 4 as with > > the other cases. While I tried to debug this I narrowed it down to the > > changes in fold_binary(), but I don't really know how to fix this, so > > I could use some help here. > > The main thing is that this is really PR 32120. The problem is only > related to the > merge because of the way fold_binary works. I'm not sure that's related, what's happening in my example is that the call to fold_plusminus_mult_expr() defeats the optimization attempted in pointer_int_sum(). If I use the patch below to restrict the condition, my problem is fixed, but PR32120 is unchanged. Actually if I compare the final_cleanup dump of PR32120 with the output from gcc 4.1, they are basically identical. bye, Roman --- gcc/fold-const.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Index: gcc/gcc/fold-const.c =================================================================== --- gcc.orig/gcc/fold-const.c +++ gcc/gcc/fold-const.c @@ -9173,8 +9173,8 @@ fold_binary (enum tree_code code, tree t /* Handle (A1 * C1) + (A2 * C2) with A1, A2 or C1, C2 being the same or one. */ - if ((TREE_CODE (arg0) == MULT_EXPR - || TREE_CODE (arg1) == MULT_EXPR) + if (TREE_CODE (arg0) == MULT_EXPR + && TREE_CODE (arg1) == MULT_EXPR && (!FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)) { tree tem = fold_plusminus_mult_expr (code, type, arg0, arg1);