aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-07-24 08:55:11 +0200
committerRichard Biener <rguenther@suse.de>2023-07-24 09:50:33 +0200
commit50b5feaa94c26d01fed13f1119f025ae2bc75d2b (patch)
tree6459681aaf5ca714fbed5e421013b2709bba9bf0 /gcc
parentfb132cdfb204bc12851eb1d5852eef6f03c13af3 (diff)
downloadgcc-50b5feaa94c26d01fed13f1119f025ae2bc75d2b.zip
gcc-50b5feaa94c26d01fed13f1119f025ae2bc75d2b.tar.gz
gcc-50b5feaa94c26d01fed13f1119f025ae2bc75d2b.tar.bz2
tree-optimization/110777 - abnormals and recent PRE optimization
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/pr110777.c22
-rw-r--r--gcc/tree-ssa-sccvn.cc4
2 files changed, 25 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/pr110777.c b/gcc/testsuite/gcc.dg/pr110777.c
new file mode 100644
index 0000000..253c2a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110777.c
@@ -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);
+}
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index ebe8006..32e06fa 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -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;