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 PR53085


This fixes redundant store elimination in FRE/PRE to preserve
volatile stores.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
trunk and the branch.

Richard.

2012-04-24  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/53085
	* tree-ssa-pre.c (eliminate): Do not eliminate volatile redundant
	stores.

	* g++.dg/torture/pr53085.C: New testcase.

Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c	(revision 186761)
--- gcc/tree-ssa-pre.c	(working copy)
*************** eliminate (void)
*** 4409,4414 ****
--- 4409,4415 ----
  	     has the same value number as its rhs.  If so, the store is
  	     dead.  */
  	  else if (gimple_assign_single_p (stmt)
+ 		   && !gimple_has_volatile_ops (stmt)
  		   && !is_gimple_reg (gimple_assign_lhs (stmt))
  		   && (TREE_CODE (rhs) == SSA_NAME
  		       || is_gimple_min_invariant (rhs)))
Index: gcc/testsuite/g++.dg/torture/pr53085.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr53085.C	(revision 0)
--- gcc/testsuite/g++.dg/torture/pr53085.C	(revision 0)
***************
*** 0 ****
--- 1,17 ----
+ // { dg-do compile }
+ // { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } }
+ // { dg-options "-fdump-tree-optimized" }
+ 
+ class aa{
+     void f();
+ private:
+     volatile int a;
+ };
+ 
+ void aa::f(){
+     a=1;
+     a=1;
+ }
+ 
+ // { dg-final { scan-tree-dump-times "a ={v} 1;" 2 "optimized" } }
+ // { dg-final { cleanup-tree-dump "optimized" } }


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