[gcc r17-2726] testsuite/aarch64: accept either csel polarity in fuse_cmp_csel tests

Kyrylo Tkachov via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:31216a506dc6563dffc0c964800bf68c98ce38c1

commit r17-2726-g31216a506dc6563dffc0c964800bf68c98ce38c1
Author: Kyrylo Tkachov <[email protected]>
Date:   Sun Jul 26 05:39:37 2026 -0700

    testsuite/aarch64: accept either csel polarity in fuse_cmp_csel tests
    
    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.
    
    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]>

Diff:
---
 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 9fcca5043ece..5735fb6a1e95 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 be0fb8f935de..f6b36932a77f 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
 */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.