]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "forwprop: Fix copy prop for alignment after the final folding [PR122086]"
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Thu, 30 Oct 2025 00:16:14 +0000 (17:16 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Thu, 30 Oct 2025 08:17:07 +0000 (01:17 -0700)
This reverts commit 8590b32deac05e6eb368b72bd353749134120a1f.

gcc/testsuite/c-c++-common/ubsan/align-5.c
gcc/testsuite/gcc.dg/pr107389.c [moved from gcc/testsuite/gcc.dg/torture/pr107389.c with 73% similarity]
gcc/tree-ssa-forwprop.cc

index 6d2ac26612bb89516eb8b1aa7e301ff234aa48a6..484790134a66076203d4a380e94a73c6b03f275d 100644 (file)
@@ -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" } } */
similarity index 73%
rename from gcc/testsuite/gcc.dg/torture/pr107389.c
rename to gcc/testsuite/gcc.dg/pr107389.c
index 23c2776ab736a1ffb724a0f693bffd21da0752f9..deb633807044828ff31710dfead76709c84b8b80 100644 (file)
@@ -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)
 {
index 79ac25f7ed5752a13084e789939682f4e8fb5ee0..68e80baa46c0e580527e2f6710abcfb0ee4807a3 100644 (file)
@@ -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);
          }