]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/100414 - compute dominance info in phiopt
authorRichard Biener <rguenther@suse.de>
Tue, 4 May 2021 11:39:14 +0000 (13:39 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 5 May 2021 07:52:45 +0000 (09:52 +0200)
phiopt now has dominator queries but fails to compute dominance
info.

2021-05-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/100414
* tree-ssa-phiopt.c (get_non_trapping): Do not compute dominance
info here.
(tree_ssa_phiopt_worker): But unconditionally here.

* gcc.dg/pr100414.c: New testcase.

(cherry picked from commit 7a3897661151cf8cc77d11f7a98fc64259210748)

gcc/testsuite/gcc.dg/pr100414.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

diff --git a/gcc/testsuite/gcc.dg/pr100414.c b/gcc/testsuite/gcc.dg/pr100414.c
new file mode 100644 (file)
index 0000000..7876f6b
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce -fno-tree-dse -fchecking" } */
+
+int i;
+void
+foo (void)
+{
+  i &= i && __builtin_bswap16 (i);
+}
index aa48f447d23c4809f6b1c3e0cd7694b8da5056e3..5831a7764a49e694f09f7c71ae7cf0f0c6750669 100644 (file)
@@ -174,6 +174,8 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads, bool early_p)
   bool cfgchanged = false;
   hash_set<tree> *nontrap = 0;
 
+  calculate_dominance_info (CDI_DOMINATORS);
+
   if (do_store_elim)
     /* Calculate the set of non-trapping memory accesses.  */
     nontrap = get_non_trapping ();
@@ -2438,9 +2440,6 @@ get_non_trapping (void)
 {
   nt_call_phase = 0;
   hash_set<tree> *nontrap = new hash_set<tree>;
-  /* We're going to do a dominator walk, so ensure that we have
-     dominance information.  */
-  calculate_dominance_info (CDI_DOMINATORS);
 
   nontrapping_dom_walker (CDI_DOMINATORS, nontrap)
     .walk (cfun->cfg->x_entry_block_ptr);