347a78e5efdaf3ab357d37cb389a384f8a96da90
2 * Copyright © 2013 Intel Corporation
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include "brw_fs_live_variables.h"
28 /** @file brw_fs_saturate_propagation.cpp
32 opt_saturate_propagation_local(fs_visitor
*v
, bblock_t
*block
)
34 bool progress
= false;
35 int ip
= block
->end_ip
+ 1;
37 foreach_inst_in_block_reverse(fs_inst
, inst
, block
) {
40 if (inst
->opcode
!= BRW_OPCODE_MOV
||
41 inst
->dst
.file
!= GRF
||
42 inst
->src
[0].file
!= GRF
||
44 inst
->src
[0].negate
||
48 int src_var
= v
->live_intervals
->var_from_reg(&inst
->src
[0]);
49 int src_end_ip
= v
->live_intervals
->end
[src_var
];
51 bool interfered
= false;
52 foreach_inst_in_block_reverse_starting_from(fs_inst
, scan_inst
, inst
, block
) {
53 if (scan_inst
->dst
.file
== GRF
&&
54 scan_inst
->dst
.reg
== inst
->src
[0].reg
&&
55 scan_inst
->dst
.reg_offset
== inst
->src
[0].reg_offset
&&
56 !scan_inst
->is_partial_write()) {
57 if (scan_inst
->saturate
) {
58 inst
->saturate
= false;
60 } else if (src_end_ip
<= ip
|| inst
->dst
.equals(inst
->src
[0])) {
61 if (scan_inst
->can_do_saturate()) {
62 scan_inst
->saturate
= true;
63 inst
->saturate
= false;
69 for (int i
= 0; i
< scan_inst
->sources
; i
++) {
70 if ((scan_inst
->opcode
!= BRW_OPCODE_MOV
|| !scan_inst
->saturate
) &&
71 scan_inst
->src
[i
].file
== GRF
&&
72 scan_inst
->src
[i
].reg
== inst
->src
[0].reg
&&
73 scan_inst
->src
[i
].reg_offset
== inst
->src
[0].reg_offset
) {
88 fs_visitor::opt_saturate_propagation()
90 bool progress
= false;
92 calculate_live_intervals();
94 foreach_block (block
, cfg
) {
95 progress
= opt_saturate_propagation_local(this, block
) || progress
;
98 /* Live intervals are still valid. */