Consider: int foo (int *p) { *p = 0; return *p; } Here is what I get after store_ccp (with -fno-tree-dominator-opts) foo (p) { int D.1233; <bb 0>: # TMT.0_5 = V_MAY_DEF <TMT.0_4>; *p_1 = 0; # VUSE <TMT.0_5>; D.1233_2 = *p_1; return D.1233_2; } Note that the return statement isn't changed to "return 0;".
Confirmed.
My .vars dump: foo (p) { <bb 0>: *p = 0; return 0; }
Whoops, didn't want to close it!! Wanted to say that the patch from Bug 23094 fixes this for me.
Subject: Bug 21574 CVSROOT: /cvs/gcc Module name: gcc Changes by: steven@gcc.gnu.org 2005-08-17 07:27:49 Modified files: gcc : ChangeLog tree-ssa-ccp.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg/tree-ssa: pr21574.c Log message: PR tree-optimization/21574 * tree-ssa-ccp.c (likely_value): If the right hand side is a constant, return CONSTANT. (ccp_lattice_meet): Use operand_equal_p instead of simple_cst_equal. (ccp_fold, visit_assignment): Likewise. (evaluate_stmt): Handle UNDEFINED and UNKNOWN_VAL the same way. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9757&r2=2.9758 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-ccp.c.diff?cvsroot=gcc&r1=2.86&r2=2.87 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5934&r2=1.5935 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr21574.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.