On Thu, Jul 3, 2025 at 4:50 AM Richard Sandiford
<richard.sandif...@arm.com> wrote:
>
> Karl Meakin <karl.mea...@arm.com> writes:
> > This patch series adds support for the CMPBR extension. It includes the
> > new `+cmpbr` option and rules to generate the new instructions when
> > lowering conditional branches.
>
> Thanks for the update, LGTM.  I've pushed the series to trunk.

So cmpbr is broken in one case dealing with `(lt reg:DI (const_int
0))` due to matching aarch64_tbzltdi1 when if there is a possibility
of adding clobbers and aarch64_cbltdi otherwise.
I can see two ways of fixing this, move the `aarch64_cb*` patterns
before the `aarch64_tbzlt` pattern then aarch64_cbltdi will no matter
if there is a possibility of adding clobbers.
The other way is to disable `aarch64_tbzlt` patterns for TARGET_CMPBR.
Which one do you prefer?

Note this is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121385 which
shows up building libgcc with CMPBR enabled.

Thanks,
Andrew

>
> Richard
>
> > Changelog:
> > * v9:
> >   - Mark the non-far branches unlikely, so that the branch is consistently 
> > generated as:
> >   ```asm
> >         branch-if-true .L123
> >         b      not_taken
> > .L123:
> >         b      taken
> >   ```
> > * v8:
> >   - Support far branches for the `CBB` and `CBH` instructions, and add 
> > tests for them.
> >   - Mark the branch in the far branch tests likely, so that the optimizer 
> > does
> >     not invert the condition.
> >   - Use regex captures for register and label names so that the tests are 
> > less fragile.
> >   - Minor formatting fixes.
> > * v7:
> >   - Support far branches and add a test for them.
> >   - Replace `aarch64_cb_short_operand` with `aarch64_reg_or_zero_operand`.
> >   - Delete the new predicates that aren't needed anymore.
> >   - Minor formatting and comment fixes.
> > * v6:
> >   - Correct the constraint string for immediate operands.
> >   - Drop the commit for adding `%j` format specifiers. The suffix for
> >     the `cb` instruction is now calculated by the `cmp_op` code
> >     attribute.
> > * v5:
> >   - Moved Moved patch 10/10 (adding %j ...) before patch 8/10 (rules for
> >     CMPBR...). Every commit in the series should now produce a correct
> >     compiler.
> >   - Reduce excessive diff context by not passing `--function-context` to
> >     `git format-patch`.
> > * v4:
> >   - Added a commit to use HS/LO instead of CS/CC mnemonics.
> >   - Rewrite the range checks for immediate RHSes in aarch64.cc: CBGE,
> >     CBHS, CBLE and CBLS have different ranges of allowed immediates than
> >     the other comparisons.
> >
> > Karl Meakin (9):
> >   AArch64: place branch instruction rules together
> >   AArch64: reformat branch instruction rules
> >   AArch64: rename branch instruction rules
> >   AArch64: add constants for branch displacements
> >   AArch64: make `far_branch` attribute a boolean
> >   AArch64: recognize `+cmpbr` option
> >   AArch64: precommit test for CMPBR instructions
> >   AArch64: rules for CMPBR instructions
> >   AArch64: make rules for CBZ/TBZ higher priority
> >
> >  .../aarch64/aarch64-option-extensions.def     |    2 +
> >  gcc/config/aarch64/aarch64-protos.h           |    2 +
> >  gcc/config/aarch64/aarch64-simd.md            |    2 +-
> >  gcc/config/aarch64/aarch64-sme.md             |    2 +-
> >  gcc/config/aarch64/aarch64.cc                 |   39 +-
> >  gcc/config/aarch64/aarch64.h                  |    3 +
> >  gcc/config/aarch64/aarch64.md                 |  570 ++++--
> >  gcc/config/aarch64/constraints.md             |   18 +
> >  gcc/config/aarch64/iterators.md               |   30 +
> >  gcc/doc/invoke.texi                           |    3 +
> >  gcc/testsuite/gcc.target/aarch64/cmpbr.c      | 1824 +++++++++++++++++
> >  gcc/testsuite/lib/target-supports.exp         |   14 +-
> >  12 files changed, 2285 insertions(+), 224 deletions(-)
> >  create mode 100644 gcc/testsuite/gcc.target/aarch64/cmpbr.c
> >
> > --
> > 2.48.1

Reply via email to