Consider: void f (void) { int *p, *q, *r; int a[10]; p = &a[5]; q = p - 1; r = q - 1; *r = 1; } Here is what I get from the first CCP. f () { int a[10]; int * r; int * q; int * p; <bb 0>: p_1 = &a[5]; q_2 = &a[4]; r_3 = q_2 - 4B; *r_3 = 1; return; } Note that p_1 and q_2 are of the form &a[CST], but r_3 is not.
Subject: Bug 21658 CVSROOT: /cvs/gcc Module name: gcc Changes by: kazu@gcc.gnu.org 2005-05-27 16:31:29 Modified files: gcc : ChangeLog tree-ssa-ccp.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg/tree-ssa: pr21658.c Log message: gcc/ PR tree-optimization/21658 * tree-ssa-ccp.c (ccp_fold): Call fold_binary instead of fold_binary_to_constant. Likewise, call fold_unary instead of fold_unary_to_constant. testsuite/ PR tree-optimization/21658 * gcc.dg/tree-ssa/pr21658.c: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8920&r2=2.8921 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-ccp.c.diff?cvsroot=gcc&r1=2.72&r2=2.73 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5546&r2=1.5547 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr21658.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Just checked in a patch.