]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
forwprop: Allow mismatch clobbers in simple dse
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 24 Nov 2025 08:52:35 +0000 (00:52 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 24 Nov 2025 17:22:11 +0000 (09:22 -0800)
As mention in the patch that adds DSEing lhs of calls,
some testcases were xfailed due to exceptions and mismatch
of clobbers in some cases.
This allows them and un-xfails the testcase where they show
up.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-forwprop.cc (do_simple_agr_dse): Allow
for mismatched clobbers.

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/simple-dse-3.C: un-xfail.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/g++.dg/tree-ssa/simple-dse-3.C
gcc/tree-ssa-forwprop.cc

index dc31eff3be3b1e49a56ef9ab2e5357d667cbc3fa..3b3bcc0174d4bc0fd1d15bc86cf0c0139040f676 100644 (file)
@@ -20,9 +20,9 @@ void func3(int a)
   struct s1 p1 = pure1(a);
 }
 
-// { dg-final { scan-tree-dump "Removing dead call store stmt p1 =" "forwprop1" { xfail *-*-* } } }
+// { dg-final { scan-tree-dump "Removing dead call store stmt p1 =" "forwprop1"  } }
 // { dg-final { scan-tree-dump-not "Removing dead call store stmt v1 =" "forwprop1" } }
 // { dg-final { scan-tree-dump-not "Removing lhs of call stmt " "forwprop1" } }
-// { dg-final { scan-tree-dump-times "Removing dead call store stmt" 1 "forwprop1" { target { ! c++26 }  xfail *-*-* } } }
-// { dg-final { scan-tree-dump-times "Removing dead call store stmt" 2 "forwprop1" { target c++26  xfail *-*-* } } }
+// { dg-final { scan-tree-dump-times "Removing dead call store stmt" 1 "forwprop1" { target { ! c++26 } } } }
+// { dg-final { scan-tree-dump-times "Removing dead call store stmt" 2 "forwprop1" { target c++26  } } }
 
index a744e224d99507f1e8eead78de48cee76659c044..c9a57d67adec45067c6ae7812117c5ede701f122 100644 (file)
@@ -1791,7 +1791,6 @@ do_simple_agr_dse (gassign *stmt, bool full_walk)
   /* Only handle clobbers of a full decl.  */
   if (!DECL_P (lhs))
     return;
-  clobber_kind kind = (clobber_kind)CLOBBER_KIND (gimple_assign_rhs1 (stmt));
   ao_ref_init (&read, lhs);
   tree vuse = gimple_vuse (stmt);
   unsigned limit = full_walk ? param_sccvn_max_alias_queries_per_access : 4;
@@ -1813,20 +1812,20 @@ do_simple_agr_dse (gassign *stmt, bool full_walk)
          basic_block ubb = gimple_bb (use_stmt);
          if (stmt == use_stmt)
            continue;
-         /* If the use is the same kind of clobber for lhs,
+         /* If the use is a clobber for lhs,
             then it can be safely skipped; this happens with eh
             and sometimes jump threading.  */
-         if (gimple_clobber_p (use_stmt, kind)
+         if (gimple_clobber_p (use_stmt)
              && lhs == gimple_assign_lhs (use_stmt))
            continue;
          /* If the use is a phi and it is single use then check if that single use
-            is a clobber of the same kind and lhs is the same.  */
+            is a clobber and lhs is the same.  */
          if (gphi *use_phi = dyn_cast<gphi*>(use_stmt))
            {
              use_operand_p ou;
              gimple *ostmt;
              if (single_imm_use (gimple_phi_result (use_phi), &ou, &ostmt)
-                 && gimple_clobber_p (ostmt, kind)
+                 && gimple_clobber_p (ostmt)
                  && lhs == gimple_assign_lhs (ostmt))
                continue;
              /* A phi node will never be dominating the clobber.  */