]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/110777 - abnormals and recent PRE optimization
authorRichard Biener <rguenther@suse.de>
Mon, 24 Jul 2023 06:55:11 +0000 (08:55 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 24 Jul 2023 07:50:33 +0000 (09:50 +0200)
The following avoids propagating abnormals with the recent tweak
to look through PRE introduced copies between equal values.

PR tree-optimization/110777
* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
Avoid propagating abnormals.

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

gcc/testsuite/gcc.dg/pr110777.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc

diff --git a/gcc/testsuite/gcc.dg/pr110777.c b/gcc/testsuite/gcc.dg/pr110777.c
new file mode 100644 (file)
index 0000000..253c2a4
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -w" } */
+
+void pm_message (int);
+int *findOrAddBackgroundInPalette_palette_pnm;
+static void findOrAddBackgroundInPalette(unsigned *paletteSizeP,
+                                    int *backgroundIndexP) {
+  if (*paletteSizeP) {
+    *backgroundIndexP = (*paletteSizeP)++;
+    pm_message(0);
+  }
+  pm_message(findOrAddBackgroundInPalette_palette_pnm[*backgroundIndexP]);
+}
+void computeColorMap(int *backgroundIndexP) {
+  unsigned paletteSize;
+  findOrAddBackgroundInPalette(&paletteSize, backgroundIndexP);
+}
+int main() {
+  unsigned backgroundIndex;
+  _setjmp();
+  computeColorMap(&backgroundIndex);
+}
index ebe8006bb8b0c9cd0fc2fe11d11222e0af9e9d8b..32e06fae3b9f062170126ed4a82f89e957d34fc6 100644 (file)
@@ -6608,7 +6608,9 @@ eliminate_dom_walker::eliminate_avail (basic_block, tree op)
            if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS)
              {
                tree rhs1 = gimple_assign_rhs1 (ass);
-               if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME)
+               if (CONSTANT_CLASS_P (rhs1)
+                   || (TREE_CODE (rhs1) == SSA_NAME
+                       && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)))
                  av = rhs1;
              }
          return av;