static inline void * bar (void *p, void *q, int r) { return __builtin_memcpy (p, q, r); } void * foo (void *p) { return bar ((void *) 0x12345000, p, 256); } at -O2 starting with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175290 is optimized away. While the return value from memcpy is known to be constant and we know that constant, we ignore the other side-effects of the call.
Created attachment 26188 [details] gcc47-pr51683.patch Untested fix.
Author: jakub Date: Sat Dec 31 23:53:57 2011 New Revision: 182761 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182761 Log: PR tree-optimization/51683 * tree-ssa-propagate.c (substitute_and_fold): Don't optimize away calls with side-effects. * tree-ssa-ccp.c (ccp_fold_stmt): Likewise. * gcc.dg/pr51683.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr51683.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-ccp.c trunk/gcc/tree-ssa-propagate.c
Fixed.