GCC Middle and Back End API Reference
lra-coalesce.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "predict.h"
#include "df.h"
#include "insn-config.h"
#include "regs.h"
#include "memmodel.h"
#include "ira.h"
#include "recog.h"
#include "lra-int.h"
Include dependency graph for lra-coalesce.cc:

Functions

static int move_freq_compare_func (const void *v1p, const void *v2p)
 
static void merge_pseudos (int regno1, int regno2)
 
static bool substitute (rtx *loc)
 
static bool substitute_within_insn (rtx_insn *insn)
 
static bool mem_move_p (int regno1, int regno2)
 
static void update_live_info (bitmap lr_bitmap)
 
static bool coalescable_pseudo_p (int regno)
 
bool lra_coalesce (void)
 

Variables

static int * first_coalesced_pseudo
 
static int * next_coalesced_pseudo
 
static bitmap_head coalesced_pseudos_bitmap
 
int lra_coalesce_iter
 
static bitmap_head used_pseudos_bitmap
 

Function Documentation

◆ coalescable_pseudo_p()

static bool coalescable_pseudo_p ( int regno)
static
Return true if pseudo REGNO can be potentially coalesced.   

References ira_reg_equiv, lra_assert, and NULL_RTX.

Referenced by lra_coalesce().

◆ lra_coalesce()

◆ mem_move_p()

static bool mem_move_p ( int regno1,
int regno2 )
static
Return true if the move involving REGNO1 and REGNO2 is a potential
memory-memory move.      

References reg_renumber.

Referenced by lra_coalesce().

◆ merge_pseudos()

static void merge_pseudos ( int regno1,
int regno2 )
static
Merge two sets of coalesced pseudos given correspondingly by
pseudos REGNO1 and REGNO2 (more accurately merging REGNO2 group
into REGNO1 group).     Set up COALESCED_PSEUDOS_BITMAP.   

References bitmap_set_bit, coalesced_pseudos_bitmap, first_coalesced_pseudo, last, lra_reg::live_ranges, lra_copy_live_range_list(), lra_merge_live_ranges(), lra_reg_info, lra_update_biggest_mode(), and next_coalesced_pseudo.

Referenced by lra_coalesce().

◆ move_freq_compare_func()

static int move_freq_compare_func ( const void * v1p,
const void * v2p )
static
The function is used to sort moves according to their execution
frequencies.      

References BLOCK_FOR_INSN(), INSN_UID(), and REG_FREQ_FROM_BB.

Referenced by lra_coalesce().

◆ substitute()

static bool substitute ( rtx * loc)
static
Change pseudos in *LOC on their coalescing group
representatives.   

References first_coalesced_pseudo, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, NULL_RTX, REGNO, regno_reg_rtx, substitute(), XEXP, XVECEXP, and XVECLEN.

Referenced by substitute(), and substitute_within_insn().

◆ substitute_within_insn()

static bool substitute_within_insn ( rtx_insn * insn)
static
Specialize "substitute" for use on an insn.  This can't change
the insn ptr, just the contents of the insn.   

References substitute().

Referenced by lra_coalesce().

◆ update_live_info()

static void update_live_info ( bitmap lr_bitmap)
static

Variable Documentation

◆ coalesced_pseudos_bitmap

bitmap_head coalesced_pseudos_bitmap
static
Pseudos which go away after coalescing.   

Referenced by lra_coalesce(), merge_pseudos(), and update_live_info().

◆ first_coalesced_pseudo

int* first_coalesced_pseudo
static
Coalesce spilled pseudos.
   Copyright (C) 2010-2024 Free Software Foundation, Inc.
   Contributed by Vladimir Makarov <vmakarov@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
This file contains a pass making some simple RTL code
transformations by coalescing pseudos to remove some move insns.

Spilling pseudos in LRA can create memory-memory moves.  We should
remove potential memory-memory moves before the next constraint
pass because the constraint pass will generate additional insns for
such moves and all these insns will be hard to remove afterwards.

Here we coalesce only spilled pseudos.  Coalescing non-spilled
pseudos (with different hard regs) might result in spilling
additional pseudos because of possible conflicts with other
non-spilled pseudos and, as a consequence, in more constraint
passes and even LRA infinite cycling.  Trivial the same hard
register moves will be removed by subsequent compiler passes.

We don't coalesce special reload pseudos.  It complicates LRA code
a lot without visible generated code improvement.

The pseudo live-ranges are used to find conflicting pseudos during
coalescing.

Most frequently executed moves is tried to be coalesced first.   
Arrays whose elements represent the first and the next pseudo
(regno) in the coalesced pseudos group to which given pseudo (its
regno is the index) belongs.     The next of the last pseudo in the
group refers to the first pseudo in the group, in other words the
group is represented by a cyclic list.   

Referenced by lra_coalesce(), merge_pseudos(), substitute(), and update_live_info().

◆ lra_coalesce_iter

int lra_coalesce_iter
The current iteration (1, 2, ...) of the coalescing pass.   

Referenced by lra(), and lra_coalesce().

◆ next_coalesced_pseudo

int * next_coalesced_pseudo
static

Referenced by lra_coalesce(), and merge_pseudos().

◆ used_pseudos_bitmap

bitmap_head used_pseudos_bitmap
static
Pseudos used instead of the coalesced pseudos.   

Referenced by lra_coalesce(), and update_live_info().