Minor tree-ssa-dse.c bugfix

Message ID 9cf3ac7f-6629-a795-7d0e-8ade3c53184b@redhat.com
State New
Headers show
Series
  • Minor tree-ssa-dse.c bugfix
Related show

Commit Message

Jeff Law Oct. 12, 2017, 6:09 p.m.
While working with Martin L's bugfix/cleanup I came across a minor bug
in the DSE code.


Specifically it mis-handles references with negative offsets.  Example
code can be found in gcc.dg/pr48335-4.c.  Thankfully these are
relatively uncommon and we can just prune them from consideration
without having major missed-optimization concerns.

Bootstrapped & regression tested with and without Martin L's bugfixes.
Installing on the trunk.

JEff
commit 261fc575195492afbedce5ebd872a2a25fe6efb1
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Oct 12 18:09:11 2017 +0000

            * tree-ssa-dse.c (valid_ao_ref_for_dse): Reject ao_refs with
            negative offsets.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253691 138bc75d-0d04-0410-961f-82ee72b054a4

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc17b705025..d5ee088e77f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2017-10-12  Jeff Law  <law@redhat.com>
+
+	* tree-ssa-dse.c (valid_ao_ref_for_dse): Reject ao_refs with
+	negative offsets.
+
 2017-10-12  Martin Sebor  <msebor@redhat.com>
 
 	PR other/82301
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 6f58fffc693..87e2fce9ac5 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -131,6 +131,7 @@  valid_ao_ref_for_dse (ao_ref *ref)
 	  && ref->max_size != -1
 	  && ref->size != 0
 	  && ref->max_size == ref->size
+	  && ref->offset >= 0
 	  && (ref->offset % BITS_PER_UNIT) == 0
 	  && (ref->size % BITS_PER_UNIT) == 0
 	  && (ref->size != -1));