GCC Middle and Back End API Reference
ccmp.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "memmodel.h"
#include "tm_p.h"
#include "ssa.h"
#include "expmed.h"
#include "optabs.h"
#include "emit-rtl.h"
#include "stor-layout.h"
#include "tree-ssa-live.h"
#include "tree-outof-ssa.h"
#include "cfgexpand.h"
#include "ccmp.h"
#include "predict.h"
Include dependency graph for ccmp.cc:

Functions

static bool ccmp_tree_comparison_p (tree t, basic_block bb)
 
static bool ccmp_candidate_p (gimple *g, bool outer=false)
 
void get_compare_parts (tree t, int *up, rtx_code *rcode, tree *rhs1, tree *rhs2)
 
static rtx expand_ccmp_next (tree op, tree_code code, rtx prev, rtx_insn **prep_seq, rtx_insn **gen_seq)
 
static rtx expand_ccmp_expr_1 (gimple *g, rtx_insn **prep_seq, rtx_insn **gen_seq)
 
rtx expand_ccmp_expr (gimple *g, machine_mode mode)
 

Function Documentation

◆ ccmp_candidate_p()

static bool ccmp_candidate_p ( gimple * g,
bool outer = false )
static
The following functions expand conditional compare (CCMP) instructions.
Here is a short description about the over all algorithm:
  * ccmp_candidate_p is used to identify the CCMP candidate

  * expand_ccmp_expr is the main entry, which calls expand_ccmp_expr_1
    to expand CCMP.

  * expand_ccmp_expr_1 uses a recursive algorithm to expand CCMP.
    It calls two target hooks gen_ccmp_first and gen_ccmp_next to generate
    CCMP instructions.
      - gen_ccmp_first expands the first compare in CCMP.
      - gen_ccmp_next expands the following compares.

    Both hooks return a comparison with the CC register that is equivalent
    to the value of the gimple comparison.  This is used by the next CCMP
    and in the final conditional store.

  * We use cstorecc4 pattern to convert the CCmode intermediate to
    the integer mode result that expand_normal is expecting.

Since the operands of the later compares might clobber CC reg, we do not
emit the insns during expand.  We keep the insn sequences in two seq

  * prep_seq, which includes all the insns to prepare the operands.
  * gen_seq, which includes all the compare and conditional compares.

If all checks OK in expand_ccmp_expr, it emits insns in prep_seq, then
insns in gen_seq.   
Check whether G is a potential conditional compare candidate; OUTER is true if
G is the outer most AND/IOR.   

References ccmp_candidate_p(), ccmp_tree_comparison_p(), g, get_gimple_for_ssa_name(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_bb(), has_single_use(), is_gimple_assign(), and TREE_CODE.

Referenced by ccmp_candidate_p(), and expand_ccmp_expr().

◆ ccmp_tree_comparison_p()

static bool ccmp_tree_comparison_p ( tree t,
basic_block bb )
static
Conditional compare related functions
   Copyright (C) 2014-2024 Free Software Foundation, Inc.

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/>.   
Check whether T is a simple boolean variable or a SSA name
set by a comparison operator in the same basic block.   

References g, get_gimple_for_ssa_name(), gimple_assign_rhs_code(), gimple_bb(), is_gimple_assign(), tcc_comparison, TREE_CODE, TREE_CODE_CLASS, and TREE_TYPE.

Referenced by ccmp_candidate_p(), and expand_ccmp_expr_1().

◆ expand_ccmp_expr()

rtx expand_ccmp_expr ( gimple * g,
machine_mode mode )
Main entry to expand conditional compare statement G.
Return NULL_RTX if G is not a legal candidate or expand fail.
Otherwise return the target.   

References ccmp_candidate_p(), const0_rtx, delete_insns_since(), emit_cstore(), emit_insn(), expand_ccmp_expr_1(), g, gen_reg_rtx(), GET_CODE, get_last_insn(), last, NULL, NULL_RTX, optab_handler(), SELECT_CC_MODE, and XEXP.

Referenced by expand_expr_real_gassign().

◆ expand_ccmp_expr_1()

static rtx expand_ccmp_expr_1 ( gimple * g,
rtx_insn ** prep_seq,
rtx_insn ** gen_seq )
static
Expand conditional compare gimple G.  A typical CCMP sequence is like:

  CC0 = CMP (a, b);
  CC1 = CCMP (NE (CC0, 0), CMP (e, f));
  ...
  CCn = CCMP (NE (CCn-1, 0), CMP (...));

hook gen_ccmp_first is used to expand the first compare.
hook gen_ccmp_next is used to expand the following CCMP.
PREP_SEQ returns all insns to prepare opearand.
GEN_SEQ returns all compare insns.   

References ccmp_tree_comparison_p(), COSTS_N_INSNS, expand_ccmp_expr_1(), expand_ccmp_next(), g, gcc_assert, get_compare_parts(), get_gimple_for_ssa_name(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_bb(), MAX_COST, NULL, NULL_RTX, optimize_insn_for_speed_p(), seq_cost(), and targetm.

Referenced by expand_ccmp_expr(), and expand_ccmp_expr_1().

◆ expand_ccmp_next()

static rtx expand_ccmp_next ( tree op,
tree_code code,
rtx prev,
rtx_insn ** prep_seq,
rtx_insn ** gen_seq )
static
PREV is a comparison with the CC register which represents the
result of the previous CMP or CCMP.  The function expands the
next compare based on G which is ANDed/ORed with the previous
compare depending on CODE.
PREP_SEQ returns all insns to prepare opearands for compare.
GEN_SEQ returns all compare insns.   

References get_compare_parts(), get_rtx_code(), and targetm.

Referenced by expand_ccmp_expr_1().

◆ get_compare_parts()

void get_compare_parts ( tree t,
int * up,
rtx_code * rcode,
tree * rhs1,
tree * rhs2 )