2 * Copyright 2013 Vadim Girlin <vadimgirlin@gmail.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "sb_shader.h"
33 bool dce_cleanup::visit(node
& n
, bool enter
) {
36 if (n
.flags
& NF_DEAD
)
44 bool dce_cleanup::visit(alu_group_node
& n
, bool enter
) {
52 bool dce_cleanup::visit(cf_node
& n
, bool enter
) {
54 if (n
.flags
& NF_DEAD
)
59 if ((sh
.dce_flags
& DF_EXPAND
) &&
60 (n
.bc
.op_ptr
->flags
& (CF_CLAUSE
| CF_BRANCH
| CF_LOOP
)))
66 bool dce_cleanup::visit(alu_node
& n
, bool enter
) {
69 if (n
.flags
& NF_DEAD
)
77 bool dce_cleanup::visit(alu_packed_node
& n
, bool enter
) {
80 if (n
.flags
& NF_DEAD
)
88 bool dce_cleanup::visit(fetch_node
& n
, bool enter
) {
91 if (n
.flags
& NF_DEAD
)
99 bool dce_cleanup::visit(region_node
& n
, bool enter
) {
110 void dce_cleanup::cleanup_dst(node
& n
) {
111 if (!cleanup_dst_vec(n
.dst
) && remove_unused
&&
112 !n
.dst
.empty() && !(n
.flags
& NF_DONT_KILL
) && n
.parent
)
116 bool dce_cleanup::visit(container_node
& n
, bool enter
) {
122 bool dce_cleanup::cleanup_dst_vec(vvec
& vv
) {
125 for (vvec::iterator I
= vv
.begin(), E
= vv
.end(); I
!= E
; ++I
) {
130 if (v
->gvn_source
&& v
->gvn_source
->is_dead())
131 v
->gvn_source
= NULL
;
133 if (v
->is_dead() || (remove_unused
&& !v
->is_rel() && !v
->uses
))
142 } // namespace r600_sb