Post-reload compare elimination.
Copyright (C) 2010-2026 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/>.
There is a set of targets whose general-purpose move or addition
instructions clobber the flags. These targets cannot split their
CBRANCH/CSTORE etc patterns before reload is complete, lest reload
itself insert these instructions in between the flags setter and user.
Because these targets cannot split the compare from the use, they
cannot make use of the comparison elimination offered by the combine pass.
This is a small pass intended to provide comparison elimination similar to
what was available via NOTICE_UPDATE_CC for cc0 targets.
This pass assumes:
(0) CBRANCH/CSTORE etc have been split in pass_split_after_reload.
(1) All comparison patterns are represented as
[(set (reg:CC) (compare:CC (reg) (reg_or_immediate)))]
(2) All insn patterns that modify the flags are represented as
[(set (reg) (operation)
(clobber (reg:CC))]
(3) If an insn of form (2) can usefully set the flags, there is
another pattern of the form
[(set (reg:CCM) (compare:CCM (operation) (immediate)))
(set (reg) (operation)]
The mode CCM will be chosen as if by SELECT_CC_MODE.
Note that unlike NOTICE_UPDATE_CC, we do not handle memory operands.
This could be handled as a future enhancement.
These structures describe a comparison and how it is used.