On Mon, Jul 27, 2026 at 4:32 AM <[email protected]> wrote:
>
> From: Kyrylo Tkachov <[email protected]>
>
> These tests exist to check that the compare and the csel stay adjacent so
> that the Neoverse V2 CMP+CSEL fusion can fire.  The condition code itself
> is incidental: for a > b ? d : e either polarity is correct, costs the
> same three instructions, and keeps the pair adjacent, and
> aarch_macro_fusion_pair_p does not look at the condition.
>
> fuse_cmp_csel-1.c was added by r17-1507-gc43fed44d9ac ("phiopt: Allow
> factoring out of more than just single operand operations") with a gt
> expectation, and the same commit switched the existing fuse_cmp_csel.c
> directives from le to gt.  Eight days later r17-1571-ga05a055bb2fb
> ("phiopt: reorganize factoring/cselim-limited for phiopt") made
> pass_phiopt return TODO_cleanup_cfg when it factors, since factoring does
> leave empty blocks behind.  The diamond is now cleaned up one pass
> earlier, crited1 re-splits the newly critical edge and the following
> cleanup_cfg removes the other forwarder, leaving the mirror image of the
> old CFG.  Expand emits the inverted conditional jump and if-conversion
> produces
>
>   cmp  w0, w1
>   csel w3, w4, w3, le
>
> so the gt expectation was stale almost as soon as it landed.
>
> Rather than swap one hard-coded condition for another, accept both.  That
> keeps the tests pinned to what they are actually testing and stops them
> breaking again the next time a middle-end change flips the CFG shape.

This was on my list of things to fix, so thanks for fixing this.
This was also PR 125927 which I have linked to the commit now and closed it.

Thanks,
Andrea

>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/aarch64/fuse_cmp_csel-1.c: Accept csel with either
>         le or gt.
>         * gcc.target/aarch64/fuse_cmp_csel.c: Likewise.
>
> Signed-off-by: Kyrylo Tkachov <[email protected]>
> ---
>  gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel-1.c | 4 ++--
>  gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel.c   | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel-1.c 
> b/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel-1.c
> index 9fcca5043ec..5735fb6a1e9 100644
> --- a/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel-1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel-1.c
> @@ -6,7 +6,7 @@
>  ** f1:
>  **     ...
>  **     cmp     w[0-9]+, w[0-9]+
> -**     csel    w[0-9]+, w[0-9]+, w[0-9]+, gt
> +**     csel    w[0-9]+, w[0-9]+, w[0-9]+, (le|gt)
>  **     add     w[0-9]+, w[0-9]+, w[0-9]+
>  **     ret
>  */
> @@ -22,7 +22,7 @@ int f1 (int a, int b, int c, int d, int e)
>  ** f2:
>  **     ...
>  **     cmp     x[0-9]+, x[0-9]+
> -**     csel    x[0-9]+, x[0-9]+, x[0-9]+, gt
> +**     csel    x[0-9]+, x[0-9]+, x[0-9]+, (le|gt)
>  **     add     x[0-9]+, x[0-9]+, x[0-9]+
>  **     ret
>  */
> diff --git a/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel.c 
> b/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel.c
> index be0fb8f935d..f6b36932a77 100644
> --- a/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel.c
> +++ b/gcc/testsuite/gcc.target/aarch64/fuse_cmp_csel.c
> @@ -10,7 +10,7 @@
>  ** f1: { xfail *-*-* }
>  **     ...
>  **     cmp     w[0-9]+, w[0-9]+
> -**     csel    w[0-9]+, w[0-9]+, w[0-9]+, gt
> +**     csel    w[0-9]+, w[0-9]+, w[0-9]+, (le|gt)
>  **     add     w[0-9]+, w[0-9]+, w[0-9]+
>  **     ret
>  */
> @@ -26,7 +26,7 @@ int f1 (int a, int b, int c)
>  ** f2: { xfail *-*-* }
>  **     ...
>  **     cmp     x[0-9]+, x[0-9]+
> -**     csel    x[0-9]+, x[0-9]+, x[0-9]+, gt
> +**     csel    x[0-9]+, x[0-9]+, x[0-9]+, (le|gt)
>  **     add     x[0-9]+, x[0-9]+, x[0-9]+
>  **     ret
>  */
> --
> 2.50.1 (Apple Git-155)
>

Reply via email to