This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR70701


The following fixes a missed optimization when value-numbering
translates through memcpy calls.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2016-04-18  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/70701
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Resolve fully constant
	references after translating through a memcpy.

	* gcc.dg/tree-ssa/ssa-fre-53.c: New testcase.

Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 235017)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** vn_reference_lookup_3 (ao_ref *ref, tree
*** 2152,2157 ****
--- 2340,2351 ----
        vr->operands[1] = op;
        vr->hashcode = vn_reference_compute_hash (vr);
  
+       /* Try folding the new reference to a constant.  */
+       tree val = fully_constant_vn_reference_p (vr);
+       if (val)
+ 	return vn_reference_lookup_or_insert_for_pieces
+ 		 (vuse, vr->set, vr->type, vr->operands, val);
+ 
        /* Adjust *ref from the new operands.  */
        if (!ao_ref_init_from_vn_reference (&r, vr->set, vr->type, vr->operands))
  	return (void *)-1;
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-53.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-53.c	(revision 0)
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-53.c	(working copy)
***************
*** 0 ****
--- 1,11 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -fno-tree-forwprop -fdump-tree-fre1" } */
+ 
+ const int a[]={1,2,3};
+ int f(){
+     int*b=__builtin_malloc(12);
+     __builtin_memcpy(b,a,12);
+     return b[0];
+ }
+ 
+ /* { dg-final { scan-tree-dump "return 1;" "fre1" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]