GCC with patches for Dreamcast
修订版 | 55bac5c2824dcb4bdae5b309b2b2a26703f273f0 (tree) |
---|---|
时间 | 2021-03-17 19:19:36 |
作者 | Richard Biener <rguenther@suse...> |
Commiter | Richard Biener |
tree-optimization/98282 - classify V_C_E<constant> as nary
This avoids running into memory reference code in compute_avail by
properly classifying unfolded reference trees on constants.
2021-01-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/98282
* tree-ssa-sccvn.c (vn_get_stmt_kind): Classify tcc_reference on
invariants as VN_NARY.
* g++.dg/opt/pr98282.C: New testcase.
(cherry picked from commit edb7dbc25de455300ce066a2ebe728256ea46e3a)
@@ -0,0 +1,80 @@ | ||
1 | +// PR tree-optimization/98282 | |
2 | +// { dg-do compile { target c++11 } } | |
3 | +// { dg-options "-O2" } | |
4 | + | |
5 | +template <typename> struct g; | |
6 | +template <typename b> struct g<b &> { typedef b c; }; | |
7 | +template <typename b> typename g<b>::c &&d(b &&e) { | |
8 | + return static_cast<typename g<b>::c &&>(e); | |
9 | +} | |
10 | +void *operator new(__SIZE_TYPE__, void *f) { return f; } | |
11 | +struct h; | |
12 | +struct k { | |
13 | + using i = h *; | |
14 | +}; | |
15 | +struct D { | |
16 | + k::i j; | |
17 | +}; | |
18 | +struct p : D { | |
19 | + p(p &&) : D() {} | |
20 | +}; | |
21 | +struct r { | |
22 | + using l = int; | |
23 | + r(r &&) : ad() {} | |
24 | + l *ad; | |
25 | +}; | |
26 | +struct s { | |
27 | + static s m(); | |
28 | +}; | |
29 | +struct t { | |
30 | + template <typename ah> void operator=(ah); | |
31 | +}; | |
32 | +struct I { | |
33 | + template <typename o> void q(o ai) { | |
34 | + *ai = aj(); | |
35 | + s::m(); | |
36 | + } | |
37 | + h aj(); | |
38 | +}; | |
39 | +template <typename...> class as; | |
40 | +struct J { | |
41 | + int a; | |
42 | + char av; | |
43 | +}; | |
44 | +template <typename...> struct aw : J { | |
45 | + void ax(...) {} | |
46 | +}; | |
47 | +template <typename... ay, typename an, typename... n> | |
48 | +struct aw<as<ay...>, an, n...> : aw<as<ay...>, n...> { | |
49 | + using az = as<ay...>; | |
50 | + using ba = aw<az, n...>; | |
51 | + char bb; | |
52 | + an &bc() { return *reinterpret_cast<an *>(this); } | |
53 | + void ax(az *bd) { | |
54 | + if (bb) | |
55 | + new (bd) an(d(bc())); | |
56 | + ba::ax(bd); | |
57 | + } | |
58 | +}; | |
59 | +template <typename... n> struct as : aw<as<n...>, n...> { | |
60 | + as(); | |
61 | + as(as &&be) { be.ax(this); } | |
62 | + void operator=(as be) { be.ax(this); } | |
63 | +}; | |
64 | +struct h { | |
65 | + as<decltype(nullptr), r, p> bg; | |
66 | +}; | |
67 | +using bh = t; | |
68 | +struct u { | |
69 | + bh bj; | |
70 | +}; | |
71 | +I bk(); | |
72 | +template <typename> void bl() { | |
73 | + h a; | |
74 | + bk().q(&a); | |
75 | +} | |
76 | +template <typename> void bn(int) { | |
77 | + u b; | |
78 | + b.bj = bl<int>; | |
79 | +} | |
80 | +void bp() { bn<int>(0); } |
@@ -461,7 +461,8 @@ vn_get_stmt_kind (gimple *stmt) | ||
461 | 461 | || code == IMAGPART_EXPR |
462 | 462 | || code == VIEW_CONVERT_EXPR |
463 | 463 | || code == BIT_FIELD_REF) |
464 | - && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME) | |
464 | + && (TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME | |
465 | + || is_gimple_min_invariant (TREE_OPERAND (rhs1, 0)))) | |
465 | 466 | return VN_NARY; |
466 | 467 | |
467 | 468 | /* Fallthrough. */ |