https://gcc.gnu.org/g:f90843dce1beb036539fcb2cb014c171086435a1

commit r16-4727-gf90843dce1beb036539fcb2cb014c171086435a1
Author: Andrew Pinski <[email protected]>
Date:   Wed Oct 29 17:16:14 2025 -0700

    Revert "forwprop: Fix copy prop for alignment after the final folding 
[PR122086]"
    
    This reverts commit 8590b32deac05e6eb368b72bd353749134120a1f.

Diff:
---
 gcc/testsuite/c-c++-common/ubsan/align-5.c    |  4 +---
 gcc/testsuite/gcc.dg/{torture => }/pr107389.c |  3 +--
 gcc/tree-ssa-forwprop.cc                      | 33 ++++-----------------------
 3 files changed, 6 insertions(+), 34 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/ubsan/align-5.c 
b/gcc/testsuite/c-c++-common/ubsan/align-5.c
index 6d2ac26612bb..484790134a66 100644
--- a/gcc/testsuite/c-c++-common/ubsan/align-5.c
+++ b/gcc/testsuite/c-c++-common/ubsan/align-5.c
@@ -11,6 +11,4 @@ foo (char *p)
   return *q;
 }
 
-/* xfail, see PR 122038 as __builtin_assume_aligned should be instrumented 
instead
-   of only the load. */
-/* { dg-final { scan-assembler "__ubsan_handle" { xfail *-*-* } } } */
+/* { dg-final { scan-assembler "__ubsan_handle" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr107389.c 
b/gcc/testsuite/gcc.dg/pr107389.c
similarity index 73%
rename from gcc/testsuite/gcc.dg/torture/pr107389.c
rename to gcc/testsuite/gcc.dg/pr107389.c
index 23c2776ab736..deb633807044 100644
--- a/gcc/testsuite/gcc.dg/torture/pr107389.c
+++ b/gcc/testsuite/gcc.dg/pr107389.c
@@ -1,6 +1,5 @@
 /* { dg-do compile } */
-/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
-/* { dg-additional-options "-fdump-tree-optimized-alias" } */
+/* { dg-options "-fdump-tree-optimized-alias" } */
 
 unsigned foo (void *p)
 {
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 79ac25f7ed57..68e80baa46c0 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -216,31 +216,6 @@ static bitmap to_purge;
 /* Const-and-copy lattice.  */
 static vec<tree> lattice;
 
-/* forwprop_may_propagate_copy is like may_propagate_copy except
-   after the final folding, don't allow propagating of pointer ORIG
-   that have a lower alignment than the DEST name.
-   This is to prevent losing alignment information from
-   __builtin_assume_aligned for expand (See also PR 122086).  */
-static bool
-forwprop_may_propagate_copy (tree dest, tree orig,
-                            bool dest_not_abnormal_phi_edge_p = false)
-{
-  if (!may_propagate_copy (dest, orig, dest_not_abnormal_phi_edge_p))
-    return false;
-
-  /* Only check alignment for the final folding.  */
-  if (!(cfun->curr_properties & PROP_last_full_fold))
-    return true;
-
-  /* Alignment only matters for pointer types.  */
-  if (!POINTER_TYPE_P (TREE_TYPE (dest)) || !POINTER_TYPE_P (TREE_TYPE (orig)))
-    return true;
-
-  unsigned aligndest = get_pointer_alignment (dest);
-  unsigned alignorig = get_pointer_alignment (orig);
-  return aligndest <= alignorig;
-}
-
 /* Set the lattice entry for NAME to VAL.  */
 static void
 fwprop_set_lattice_val (tree name, tree val)
@@ -5202,7 +5177,7 @@ pass_forwprop::execute (function *fun)
            }
          if (all_same)
            {
-             if (forwprop_may_propagate_copy (res, first))
+             if (may_propagate_copy (res, first))
                to_remove_defs.safe_push (SSA_NAME_VERSION (res));
              fwprop_set_lattice_val (res, first);
            }
@@ -5557,7 +5532,7 @@ pass_forwprop::execute (function *fun)
                {
                  if (!is_gimple_debug (stmt))
                    bitmap_set_bit (simple_dce_worklist, SSA_NAME_VERSION 
(use));
-                 if (forwprop_may_propagate_copy (use, val))
+                 if (may_propagate_copy (use, val))
                    {
                      propagate_value (usep, val);
                      substituted_p = true;
@@ -5720,7 +5695,7 @@ pass_forwprop::execute (function *fun)
                  /* If we can propagate the lattice-value mark the
                     stmt for removal.  */
                  if (val != lhs
-                     && forwprop_may_propagate_copy (lhs, val))
+                     && may_propagate_copy (lhs, val))
                    to_remove_defs.safe_push (SSA_NAME_VERSION (lhs));
                  fwprop_set_lattice_val (lhs, val);
                }
@@ -5742,7 +5717,7 @@ pass_forwprop::execute (function *fun)
              continue;
            tree val = fwprop_ssa_val (arg);
            if (val != arg
-               && forwprop_may_propagate_copy (arg, val, !(e->flags & 
EDGE_ABNORMAL)))
+               && may_propagate_copy (arg, val, !(e->flags & EDGE_ABNORMAL)))
              propagate_value (use_p, val);
          }

Reply via email to