1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
From 32e55402bb0fc442831d775a516f2def4f948f93 Mon Sep 17 00:00:00 2001
From: rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 12 May 2011 14:08:00 +0000
Subject: [PATCH] 2011-05-12 Richard Guenther <rguenther@suse.de>
Backport from mainline
2011-05-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/48822
* tree-ssa-sccvn.c (set_ssa_val_to): Never go up the lattice.
(process_scc): Indicate which iteration we start.
* gcc.dg/torture/pr48822.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173705 138bc75d-0d04-0410-961f-82ee72b054a4
index be253f4..81b52db 100644
new file mode 100644
index 0000000..b619f36
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48822.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+void foo (int *, int *);
+int bar ()
+{
+ int a = 0;
+ int b = 0;
+ if (b != 0)
+ {
+ int ax = a;
+ int bx = b;
+ while (bx != 0)
+ {
+ int tem = ax % bx;
+ ax = bx;
+ bx = tem;
+ }
+ }
+ foo (&a, &b);
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 9222cb5..eb88969 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2103,12 +2103,26 @@ print_scc (FILE *out, VEC (tree, heap) *scc)
static inline bool
set_ssa_val_to (tree from, tree to)
{
- tree currval;
+ tree currval = SSA_VAL (from);
- if (from != to
- && TREE_CODE (to) == SSA_NAME
- && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
- to = from;
+ if (from != to)
+ {
+ if (currval == from)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Not changing value number of ");
+ print_generic_expr (dump_file, from, 0);
+ fprintf (dump_file, " from VARYING to ");
+ print_generic_expr (dump_file, to, 0);
+ fprintf (dump_file, "\n");
+ }
+ return false;
+ }
+ else if (TREE_CODE (to) == SSA_NAME
+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
+ to = from;
+ }
/* The only thing we allow as value numbers are VN_TOP, ssa_names
and invariants. So assert that here. */
@@ -2125,8 +2139,6 @@ set_ssa_val_to (tree from, tree to)
print_generic_expr (dump_file, to, 0);
}
- currval = SSA_VAL (from);
-
if (currval != to && !operand_equal_p (currval, to, OEP_PURE_SAME))
{
VN_INFO (from)->valnum = to;
@@ -3124,6 +3136,8 @@ process_scc (VEC (tree, heap) *scc)
{
changed = false;
iterations++;
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Starting iteration %d\n", iterations);
/* As we are value-numbering optimistically we have to
clear the expression tables and the simplified expressions
in each iteration until we converge. */
--
1.7.0.4
|