re PR tree-optimization/56049 (Simplification to constants not done)
authorRichard Biener <rguenther@suse.de>
Tue, 16 Apr 2019 07:55:41 +0000 (07:55 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 16 Apr 2019 07:55:41 +0000 (07:55 +0000)
2019-04-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/56049
* tree-ssa-loop-im.c (mem_ref_hasher::equal): Elide alias-set
equality check if alias-set zero will prevail.

* gfortran.dg/pr56049.f90: New testcase.

From-SVN: r270378

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr56049.f90 [new file with mode: 0644]
gcc/tree-ssa-loop-im.c

index 018d006c47d44a13d85adcb18ce2c493b57cbf16..393e176175299f52483c4defb4ee88d54947e91e 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56049
+       * tree-ssa-loop-im.c (mem_ref_hasher::equal): Elide alias-set
+       equality check if alias-set zero will prevail.
+
 2019-04-15  Jeff Law  <law@redhat.com>
 
        * config/microblaze/microblaze.c (microblaze_expand_block_move): Treat
index aacdaff51ed6b7fad7e63cf756508c450ec72ba8..9f89fba152e61ea6ef799fd58a4caeb164f04eb5 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56049
+       * gfortran.dg/pr56049.f90: New testcase.
+
 2019-04-15  Richard Biener  <rguenther@suse.de>
 
        PR debug/90074
diff --git a/gcc/testsuite/gfortran.dg/pr56049.f90 b/gcc/testsuite/gfortran.dg/pr56049.f90
new file mode 100644 (file)
index 0000000..d760320
--- /dev/null
@@ -0,0 +1,29 @@
+! { dg-do compile }
+! { dg-options "-O3 -fdump-tree-optimized" }
+
+program inline
+
+    integer i
+    integer a(8,8), b(8,8)
+
+    a = 0
+    do i = 1, 10000000
+        call add(b, a, 1)
+        a = b
+    end do
+
+    print *, a
+
+contains
+
+    subroutine add(b, a, o)
+        integer, intent(inout) :: b(8,8)
+        integer, intent(in) :: a(8,8), o
+        b = a + o
+    end subroutine add
+
+end program inline
+
+! Check there's no loop left, just two bb 2 in two functions.
+! { dg-final { scan-tree-dump-times "<bb \[0-9\]*>" 2 "optimized" } }
+! { dg-final { scan-tree-dump-times "<bb 2>" 2 "optimized" } }
index 631dd9059ae51cea0e5fa3985a98d757f02a9783..56d8e8e4330b9d013d4559fccdf19b768cbd86fb 100644 (file)
@@ -178,7 +178,17 @@ mem_ref_hasher::equal (const im_mem_ref *mem1, const ao_ref *obj2)
            && known_eq (mem1->mem.size, obj2->size)
            && known_eq (mem1->mem.max_size, obj2->max_size)
            && mem1->mem.volatile_p == obj2->volatile_p
-           && mem1->mem.ref_alias_set == obj2->ref_alias_set
+           && (mem1->mem.ref_alias_set == obj2->ref_alias_set
+               /* We are not canonicalizing alias-sets but for the
+                  special-case we didn't canonicalize yet and the
+                  incoming ref is a alias-set zero MEM we pick
+                  the correct one already.  */
+               || (!mem1->ref_canonical
+                   && (TREE_CODE (obj2->ref) == MEM_REF
+                       || TREE_CODE (obj2->ref) == TARGET_MEM_REF)
+                   && obj2->ref_alias_set == 0)
+               /* Likewise if there's a canonical ref with alias-set zero.  */
+               || (mem1->ref_canonical && mem1->mem.ref_alias_set == 0))
            && types_compatible_p (TREE_TYPE (mem1->mem.ref),
                                   TREE_TYPE (obj2->ref)));
   else