1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2012 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci * Authors:
24bf215546Sopenharmony_ci *    Eric Anholt <eric@anholt.net>
25bf215546Sopenharmony_ci *
26bf215546Sopenharmony_ci */
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include "brw_fs.h"
29bf215546Sopenharmony_ci#include "brw_fs_live_variables.h"
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ciusing namespace brw;
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci#define MAX_INSTRUCTION (1 << 30)
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci/** @file brw_fs_live_variables.cpp
36bf215546Sopenharmony_ci *
37bf215546Sopenharmony_ci * Support for calculating liveness information about virtual GRFs.
38bf215546Sopenharmony_ci *
39bf215546Sopenharmony_ci * This produces a live interval for each whole virtual GRF.  We could
40bf215546Sopenharmony_ci * choose to expose per-component live intervals for VGRFs of size > 1,
41bf215546Sopenharmony_ci * but we currently do not.  It is easier for the consumers of this
42bf215546Sopenharmony_ci * information to work with whole VGRFs.
43bf215546Sopenharmony_ci *
44bf215546Sopenharmony_ci * However, we internally track use/def information at the per-GRF level for
45bf215546Sopenharmony_ci * greater accuracy.  Large VGRFs may be accessed piecemeal over many
46bf215546Sopenharmony_ci * (possibly non-adjacent) instructions.  In this case, examining a single
47bf215546Sopenharmony_ci * instruction is insufficient to decide whether a whole VGRF is ultimately
48bf215546Sopenharmony_ci * used or defined.  Tracking individual components allows us to easily
49bf215546Sopenharmony_ci * assemble this information.
50bf215546Sopenharmony_ci *
51bf215546Sopenharmony_ci * See Muchnick's Advanced Compiler Design and Implementation, section
52bf215546Sopenharmony_ci * 14.1 (p444).
53bf215546Sopenharmony_ci */
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_civoid
56bf215546Sopenharmony_cifs_live_variables::setup_one_read(struct block_data *bd,
57bf215546Sopenharmony_ci                                  int ip, const fs_reg &reg)
58bf215546Sopenharmony_ci{
59bf215546Sopenharmony_ci   int var = var_from_reg(reg);
60bf215546Sopenharmony_ci   assert(var < num_vars);
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_ci   start[var] = MIN2(start[var], ip);
63bf215546Sopenharmony_ci   end[var] = MAX2(end[var], ip);
64bf215546Sopenharmony_ci
65bf215546Sopenharmony_ci   /* The use[] bitset marks when the block makes use of a variable (VGRF
66bf215546Sopenharmony_ci    * channel) without having completely defined that variable within the
67bf215546Sopenharmony_ci    * block.
68bf215546Sopenharmony_ci    */
69bf215546Sopenharmony_ci   if (!BITSET_TEST(bd->def, var))
70bf215546Sopenharmony_ci      BITSET_SET(bd->use, var);
71bf215546Sopenharmony_ci}
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_civoid
74bf215546Sopenharmony_cifs_live_variables::setup_one_write(struct block_data *bd, fs_inst *inst,
75bf215546Sopenharmony_ci                                   int ip, const fs_reg &reg)
76bf215546Sopenharmony_ci{
77bf215546Sopenharmony_ci   int var = var_from_reg(reg);
78bf215546Sopenharmony_ci   assert(var < num_vars);
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci   start[var] = MIN2(start[var], ip);
81bf215546Sopenharmony_ci   end[var] = MAX2(end[var], ip);
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_ci   /* The def[] bitset marks when an initialization in a block completely
84bf215546Sopenharmony_ci    * screens off previous updates of that variable (VGRF channel).
85bf215546Sopenharmony_ci    */
86bf215546Sopenharmony_ci   if (inst->dst.file == VGRF) {
87bf215546Sopenharmony_ci      if (!inst->is_partial_write() && !BITSET_TEST(bd->use, var))
88bf215546Sopenharmony_ci         BITSET_SET(bd->def, var);
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ci      BITSET_SET(bd->defout, var);
91bf215546Sopenharmony_ci   }
92bf215546Sopenharmony_ci}
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci/**
95bf215546Sopenharmony_ci * Sets up the use[] and def[] bitsets.
96bf215546Sopenharmony_ci *
97bf215546Sopenharmony_ci * The basic-block-level live variable analysis needs to know which
98bf215546Sopenharmony_ci * variables get used before they're completely defined, and which
99bf215546Sopenharmony_ci * variables are completely defined before they're used.
100bf215546Sopenharmony_ci *
101bf215546Sopenharmony_ci * These are tracked at the per-component level, rather than whole VGRFs.
102bf215546Sopenharmony_ci */
103bf215546Sopenharmony_civoid
104bf215546Sopenharmony_cifs_live_variables::setup_def_use()
105bf215546Sopenharmony_ci{
106bf215546Sopenharmony_ci   int ip = 0;
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci   foreach_block (block, cfg) {
109bf215546Sopenharmony_ci      assert(ip == block->start_ip);
110bf215546Sopenharmony_ci      if (block->num > 0)
111bf215546Sopenharmony_ci	 assert(cfg->blocks[block->num - 1]->end_ip == ip - 1);
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_ci      struct block_data *bd = &block_data[block->num];
114bf215546Sopenharmony_ci
115bf215546Sopenharmony_ci      foreach_inst_in_block(fs_inst, inst, block) {
116bf215546Sopenharmony_ci	 /* Set use[] for this instruction */
117bf215546Sopenharmony_ci	 for (unsigned int i = 0; i < inst->sources; i++) {
118bf215546Sopenharmony_ci            fs_reg reg = inst->src[i];
119bf215546Sopenharmony_ci
120bf215546Sopenharmony_ci            if (reg.file != VGRF)
121bf215546Sopenharmony_ci               continue;
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci            for (unsigned j = 0; j < regs_read(inst, i); j++) {
124bf215546Sopenharmony_ci               setup_one_read(bd, ip, reg);
125bf215546Sopenharmony_ci               reg.offset += REG_SIZE;
126bf215546Sopenharmony_ci            }
127bf215546Sopenharmony_ci	 }
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci         bd->flag_use[0] |= inst->flags_read(devinfo) & ~bd->flag_def[0];
130bf215546Sopenharmony_ci
131bf215546Sopenharmony_ci         /* Set def[] for this instruction */
132bf215546Sopenharmony_ci         if (inst->dst.file == VGRF) {
133bf215546Sopenharmony_ci            fs_reg reg = inst->dst;
134bf215546Sopenharmony_ci            for (unsigned j = 0; j < regs_written(inst); j++) {
135bf215546Sopenharmony_ci               setup_one_write(bd, inst, ip, reg);
136bf215546Sopenharmony_ci               reg.offset += REG_SIZE;
137bf215546Sopenharmony_ci            }
138bf215546Sopenharmony_ci	 }
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ci         if (!inst->predicate && inst->exec_size >= 8)
141bf215546Sopenharmony_ci            bd->flag_def[0] |= inst->flags_written(devinfo) & ~bd->flag_use[0];
142bf215546Sopenharmony_ci
143bf215546Sopenharmony_ci	 ip++;
144bf215546Sopenharmony_ci      }
145bf215546Sopenharmony_ci   }
146bf215546Sopenharmony_ci}
147bf215546Sopenharmony_ci
148bf215546Sopenharmony_ci/**
149bf215546Sopenharmony_ci * The algorithm incrementally sets bits in liveout and livein,
150bf215546Sopenharmony_ci * propagating it through control flow.  It will eventually terminate
151bf215546Sopenharmony_ci * because it only ever adds bits, and stops when no bits are added in
152bf215546Sopenharmony_ci * a pass.
153bf215546Sopenharmony_ci */
154bf215546Sopenharmony_civoid
155bf215546Sopenharmony_cifs_live_variables::compute_live_variables()
156bf215546Sopenharmony_ci{
157bf215546Sopenharmony_ci   bool cont = true;
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci   while (cont) {
160bf215546Sopenharmony_ci      cont = false;
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci      foreach_block_reverse (block, cfg) {
163bf215546Sopenharmony_ci         struct block_data *bd = &block_data[block->num];
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ci	 /* Update liveout */
166bf215546Sopenharmony_ci	 foreach_list_typed(bblock_link, child_link, link, &block->children) {
167bf215546Sopenharmony_ci       struct block_data *child_bd = &block_data[child_link->block->num];
168bf215546Sopenharmony_ci
169bf215546Sopenharmony_ci	    for (int i = 0; i < bitset_words; i++) {
170bf215546Sopenharmony_ci               BITSET_WORD new_liveout = (child_bd->livein[i] &
171bf215546Sopenharmony_ci                                          ~bd->liveout[i]);
172bf215546Sopenharmony_ci               if (new_liveout) {
173bf215546Sopenharmony_ci                  bd->liveout[i] |= new_liveout;
174bf215546Sopenharmony_ci                  cont = true;
175bf215546Sopenharmony_ci               }
176bf215546Sopenharmony_ci	    }
177bf215546Sopenharmony_ci            BITSET_WORD new_liveout = (child_bd->flag_livein[0] &
178bf215546Sopenharmony_ci                                       ~bd->flag_liveout[0]);
179bf215546Sopenharmony_ci            if (new_liveout) {
180bf215546Sopenharmony_ci               bd->flag_liveout[0] |= new_liveout;
181bf215546Sopenharmony_ci               cont = true;
182bf215546Sopenharmony_ci            }
183bf215546Sopenharmony_ci	 }
184bf215546Sopenharmony_ci
185bf215546Sopenharmony_ci         /* Update livein */
186bf215546Sopenharmony_ci         for (int i = 0; i < bitset_words; i++) {
187bf215546Sopenharmony_ci            BITSET_WORD new_livein = (bd->use[i] |
188bf215546Sopenharmony_ci                                      (bd->liveout[i] &
189bf215546Sopenharmony_ci                                       ~bd->def[i]));
190bf215546Sopenharmony_ci            if (new_livein & ~bd->livein[i]) {
191bf215546Sopenharmony_ci               bd->livein[i] |= new_livein;
192bf215546Sopenharmony_ci               cont = true;
193bf215546Sopenharmony_ci            }
194bf215546Sopenharmony_ci         }
195bf215546Sopenharmony_ci         BITSET_WORD new_livein = (bd->flag_use[0] |
196bf215546Sopenharmony_ci                                   (bd->flag_liveout[0] &
197bf215546Sopenharmony_ci                                    ~bd->flag_def[0]));
198bf215546Sopenharmony_ci         if (new_livein & ~bd->flag_livein[0]) {
199bf215546Sopenharmony_ci            bd->flag_livein[0] |= new_livein;
200bf215546Sopenharmony_ci            cont = true;
201bf215546Sopenharmony_ci         }
202bf215546Sopenharmony_ci      }
203bf215546Sopenharmony_ci   }
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ci   /* Propagate defin and defout down the CFG to calculate the union of live
206bf215546Sopenharmony_ci    * variables potentially defined along any possible control flow path.
207bf215546Sopenharmony_ci    */
208bf215546Sopenharmony_ci   do {
209bf215546Sopenharmony_ci      cont = false;
210bf215546Sopenharmony_ci
211bf215546Sopenharmony_ci      foreach_block (block, cfg) {
212bf215546Sopenharmony_ci         const struct block_data *bd = &block_data[block->num];
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_ci	 foreach_list_typed(bblock_link, child_link, link, &block->children) {
215bf215546Sopenharmony_ci       struct block_data *child_bd = &block_data[child_link->block->num];
216bf215546Sopenharmony_ci
217bf215546Sopenharmony_ci	    for (int i = 0; i < bitset_words; i++) {
218bf215546Sopenharmony_ci               const BITSET_WORD new_def = bd->defout[i] & ~child_bd->defin[i];
219bf215546Sopenharmony_ci               child_bd->defin[i] |= new_def;
220bf215546Sopenharmony_ci               child_bd->defout[i] |= new_def;
221bf215546Sopenharmony_ci               cont |= new_def;
222bf215546Sopenharmony_ci	    }
223bf215546Sopenharmony_ci	 }
224bf215546Sopenharmony_ci      }
225bf215546Sopenharmony_ci   } while (cont);
226bf215546Sopenharmony_ci}
227bf215546Sopenharmony_ci
228bf215546Sopenharmony_ci/**
229bf215546Sopenharmony_ci * Extend the start/end ranges for each variable to account for the
230bf215546Sopenharmony_ci * new information calculated from control flow.
231bf215546Sopenharmony_ci */
232bf215546Sopenharmony_civoid
233bf215546Sopenharmony_cifs_live_variables::compute_start_end()
234bf215546Sopenharmony_ci{
235bf215546Sopenharmony_ci   foreach_block (block, cfg) {
236bf215546Sopenharmony_ci      struct block_data *bd = &block_data[block->num];
237bf215546Sopenharmony_ci
238bf215546Sopenharmony_ci      for (int w = 0; w < bitset_words; w++) {
239bf215546Sopenharmony_ci         BITSET_WORD livedefin = bd->livein[w] & bd->defin[w];
240bf215546Sopenharmony_ci         BITSET_WORD livedefout = bd->liveout[w] & bd->defout[w];
241bf215546Sopenharmony_ci         BITSET_WORD livedefinout = livedefin | livedefout;
242bf215546Sopenharmony_ci         while (livedefinout) {
243bf215546Sopenharmony_ci            unsigned b = u_bit_scan(&livedefinout);
244bf215546Sopenharmony_ci            unsigned i = w * BITSET_WORDBITS + b;
245bf215546Sopenharmony_ci            if (livedefin & (1u << b)) {
246bf215546Sopenharmony_ci               start[i] = MIN2(start[i], block->start_ip);
247bf215546Sopenharmony_ci               end[i] = MAX2(end[i], block->start_ip);
248bf215546Sopenharmony_ci            }
249bf215546Sopenharmony_ci            if (livedefout & (1u << b)) {
250bf215546Sopenharmony_ci               start[i] = MIN2(start[i], block->end_ip);
251bf215546Sopenharmony_ci               end[i] = MAX2(end[i], block->end_ip);
252bf215546Sopenharmony_ci            }
253bf215546Sopenharmony_ci         }
254bf215546Sopenharmony_ci      }
255bf215546Sopenharmony_ci   }
256bf215546Sopenharmony_ci}
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_cifs_live_variables::fs_live_variables(const backend_shader *s)
259bf215546Sopenharmony_ci   : devinfo(s->devinfo), cfg(s->cfg)
260bf215546Sopenharmony_ci{
261bf215546Sopenharmony_ci   mem_ctx = ralloc_context(NULL);
262bf215546Sopenharmony_ci
263bf215546Sopenharmony_ci   num_vgrfs = s->alloc.count;
264bf215546Sopenharmony_ci   num_vars = 0;
265bf215546Sopenharmony_ci   var_from_vgrf = rzalloc_array(mem_ctx, int, num_vgrfs);
266bf215546Sopenharmony_ci   for (int i = 0; i < num_vgrfs; i++) {
267bf215546Sopenharmony_ci      var_from_vgrf[i] = num_vars;
268bf215546Sopenharmony_ci      num_vars += s->alloc.sizes[i];
269bf215546Sopenharmony_ci   }
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci   vgrf_from_var = rzalloc_array(mem_ctx, int, num_vars);
272bf215546Sopenharmony_ci   for (int i = 0; i < num_vgrfs; i++) {
273bf215546Sopenharmony_ci      for (unsigned j = 0; j < s->alloc.sizes[i]; j++) {
274bf215546Sopenharmony_ci         vgrf_from_var[var_from_vgrf[i] + j] = i;
275bf215546Sopenharmony_ci      }
276bf215546Sopenharmony_ci   }
277bf215546Sopenharmony_ci
278bf215546Sopenharmony_ci   start = ralloc_array(mem_ctx, int, num_vars);
279bf215546Sopenharmony_ci   end = rzalloc_array(mem_ctx, int, num_vars);
280bf215546Sopenharmony_ci   for (int i = 0; i < num_vars; i++) {
281bf215546Sopenharmony_ci      start[i] = MAX_INSTRUCTION;
282bf215546Sopenharmony_ci      end[i] = -1;
283bf215546Sopenharmony_ci   }
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci   vgrf_start = ralloc_array(mem_ctx, int, num_vgrfs);
286bf215546Sopenharmony_ci   vgrf_end = ralloc_array(mem_ctx, int, num_vgrfs);
287bf215546Sopenharmony_ci   for (int i = 0; i < num_vgrfs; i++) {
288bf215546Sopenharmony_ci      vgrf_start[i] = MAX_INSTRUCTION;
289bf215546Sopenharmony_ci      vgrf_end[i] = -1;
290bf215546Sopenharmony_ci   }
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci   block_data = rzalloc_array(mem_ctx, struct block_data, cfg->num_blocks);
293bf215546Sopenharmony_ci
294bf215546Sopenharmony_ci   bitset_words = BITSET_WORDS(num_vars);
295bf215546Sopenharmony_ci   for (int i = 0; i < cfg->num_blocks; i++) {
296bf215546Sopenharmony_ci      block_data[i].def = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
297bf215546Sopenharmony_ci      block_data[i].use = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
298bf215546Sopenharmony_ci      block_data[i].livein = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
299bf215546Sopenharmony_ci      block_data[i].liveout = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
300bf215546Sopenharmony_ci      block_data[i].defin = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
301bf215546Sopenharmony_ci      block_data[i].defout = rzalloc_array(mem_ctx, BITSET_WORD, bitset_words);
302bf215546Sopenharmony_ci
303bf215546Sopenharmony_ci      block_data[i].flag_def[0] = 0;
304bf215546Sopenharmony_ci      block_data[i].flag_use[0] = 0;
305bf215546Sopenharmony_ci      block_data[i].flag_livein[0] = 0;
306bf215546Sopenharmony_ci      block_data[i].flag_liveout[0] = 0;
307bf215546Sopenharmony_ci   }
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ci   setup_def_use();
310bf215546Sopenharmony_ci   compute_live_variables();
311bf215546Sopenharmony_ci   compute_start_end();
312bf215546Sopenharmony_ci
313bf215546Sopenharmony_ci   /* Merge the per-component live ranges to whole VGRF live ranges. */
314bf215546Sopenharmony_ci   for (int i = 0; i < num_vars; i++) {
315bf215546Sopenharmony_ci      const unsigned vgrf = vgrf_from_var[i];
316bf215546Sopenharmony_ci      vgrf_start[vgrf] = MIN2(vgrf_start[vgrf], start[i]);
317bf215546Sopenharmony_ci      vgrf_end[vgrf] = MAX2(vgrf_end[vgrf], end[i]);
318bf215546Sopenharmony_ci   }
319bf215546Sopenharmony_ci}
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_cifs_live_variables::~fs_live_variables()
322bf215546Sopenharmony_ci{
323bf215546Sopenharmony_ci   ralloc_free(mem_ctx);
324bf215546Sopenharmony_ci}
325bf215546Sopenharmony_ci
326bf215546Sopenharmony_cistatic bool
327bf215546Sopenharmony_cicheck_register_live_range(const fs_live_variables *live, int ip,
328bf215546Sopenharmony_ci                          const fs_reg &reg, unsigned n)
329bf215546Sopenharmony_ci{
330bf215546Sopenharmony_ci   const unsigned var = live->var_from_reg(reg);
331bf215546Sopenharmony_ci
332bf215546Sopenharmony_ci   if (var + n > unsigned(live->num_vars) ||
333bf215546Sopenharmony_ci       live->vgrf_start[reg.nr] > ip || live->vgrf_end[reg.nr] < ip)
334bf215546Sopenharmony_ci      return false;
335bf215546Sopenharmony_ci
336bf215546Sopenharmony_ci   for (unsigned j = 0; j < n; j++) {
337bf215546Sopenharmony_ci      if (live->start[var + j] > ip || live->end[var + j] < ip)
338bf215546Sopenharmony_ci         return false;
339bf215546Sopenharmony_ci   }
340bf215546Sopenharmony_ci
341bf215546Sopenharmony_ci   return true;
342bf215546Sopenharmony_ci}
343bf215546Sopenharmony_ci
344bf215546Sopenharmony_cibool
345bf215546Sopenharmony_cifs_live_variables::validate(const backend_shader *s) const
346bf215546Sopenharmony_ci{
347bf215546Sopenharmony_ci   int ip = 0;
348bf215546Sopenharmony_ci
349bf215546Sopenharmony_ci   foreach_block_and_inst(block, fs_inst, inst, s->cfg) {
350bf215546Sopenharmony_ci      for (unsigned i = 0; i < inst->sources; i++) {
351bf215546Sopenharmony_ci         if (inst->src[i].file == VGRF &&
352bf215546Sopenharmony_ci             !check_register_live_range(this, ip,
353bf215546Sopenharmony_ci                                        inst->src[i], regs_read(inst, i)))
354bf215546Sopenharmony_ci            return false;
355bf215546Sopenharmony_ci      }
356bf215546Sopenharmony_ci
357bf215546Sopenharmony_ci      if (inst->dst.file == VGRF &&
358bf215546Sopenharmony_ci          !check_register_live_range(this, ip, inst->dst, regs_written(inst)))
359bf215546Sopenharmony_ci         return false;
360bf215546Sopenharmony_ci
361bf215546Sopenharmony_ci      ip++;
362bf215546Sopenharmony_ci   }
363bf215546Sopenharmony_ci
364bf215546Sopenharmony_ci   return true;
365bf215546Sopenharmony_ci}
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_cibool
368bf215546Sopenharmony_cifs_live_variables::vars_interfere(int a, int b) const
369bf215546Sopenharmony_ci{
370bf215546Sopenharmony_ci   return !(end[b] <= start[a] ||
371bf215546Sopenharmony_ci            end[a] <= start[b]);
372bf215546Sopenharmony_ci}
373bf215546Sopenharmony_ci
374bf215546Sopenharmony_cibool
375bf215546Sopenharmony_cifs_live_variables::vgrfs_interfere(int a, int b) const
376bf215546Sopenharmony_ci{
377bf215546Sopenharmony_ci   return !(vgrf_end[a] <= vgrf_start[b] ||
378bf215546Sopenharmony_ci            vgrf_end[b] <= vgrf_start[a]);
379bf215546Sopenharmony_ci}
380