Bug 21574 - store_ccp doesn't see through a store.
Summary: store_ccp doesn't see through a store.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2005-05-14 21:14 UTC by Kazu Hirata
Modified: 2005-08-17 12:11 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-14 21:21:37


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2005-05-14 21:14:39 UTC
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;".
Comment 1 Andrew Pinski 2005-05-14 21:21:37 UTC
Confirmed.
Comment 2 Steven Bosscher 2005-08-13 10:09:14 UTC
My .vars dump: 
foo (p) 
{ 
<bb 0>: 
  *p = 0; 
  return 0; 
 
} 
 
Comment 3 Steven Bosscher 2005-08-13 10:12:03 UTC
Whoops, didn't want to close it!!  Wanted to say that the patch 
from Bug 23094 fixes this for me. 
Comment 4 GCC Commits 2005-08-17 07:29:32 UTC
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

Comment 5 Andrew Pinski 2005-08-17 12:11:12 UTC
Fixed.