From: Roger Sayle Date: Sun, 5 Jul 2026 20:19:17 +0000 (+0100) Subject: aarch64: [PR126094] Update aarch64_cmtst* patterns for new simplifications. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88752b86ff1af4589c61d5bd8592b17e481ab596;p=thirdparty%2Fgcc.git aarch64: [PR126094] Update aarch64_cmtst* patterns for new simplifications. The recent patch to simplify/canonicalize (not (neg (eq x y))) as (neg (ne x y)) [when the relevant STORE_FLAG_VALUE is 1] causes aarch64's aarch64_cmtst* patterns to fail as they were expecting the old canonical RTL. This patch adds the new canonical forms to aarch64-simd.md which corrects the testsuite failure of gcc.target/aarch64/mvn-cmeq0-1.c. Sorry for any inconvenience. 2026-07-05 Roger Sayle gcc/ChangeLog PR target/126094 * config/aarch64/aarch64-simd.md (aarch64_cmtst): Update pattern to match recent RTL simplification. (*aarch64_cmtst): Preserve the original. (*aarch64_cmtst_same_): Additional variant. --- diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index 94fb49a338b..23a8a47263a 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -8002,13 +8002,23 @@ ;; cmtst +(define_insn "aarch64_cmtst" + [(set (match_operand: 0 "register_operand" "=w") + (neg: + (ne: + (and:VDQ_I + (match_operand:VDQ_I 1 "register_operand" "w") + (match_operand:VDQ_I 2 "register_operand" "w")) + (match_operand:VDQ_I 3 "aarch64_simd_imm_zero")))) + ] + "TARGET_SIMD" + "cmtst\t%0, %1, %2" + [(set_attr "type" "neon_tst")] +) ;; Although neg (ne (and x y) 0) is the natural way of expressing a cmtst, -;; we don't have any insns using ne, and aarch64_vcond outputs -;; not (neg (eq (and x y) 0)) -;; which is rewritten by simplify_rtx as -;; plus (eq (and x y) 0) -1. +;; earlier versions of GCC simplified this as plus (eq (and x y) 0) -1. -(define_insn "aarch64_cmtst" +(define_insn "*aarch64_cmtst" [(set (match_operand: 0 "register_operand" "=w") (plus: (eq: @@ -8023,6 +8033,22 @@ [(set_attr "type" "neon_tst")] ) +;; One can also get a cmtsts by having to combine a +;; neg (ne x 0) in which case you rewrite it to +;; a comparison against itself + +(define_insn "*aarch64_cmtst_same_" + [(set (match_operand: 0 "register_operand" "=w") + (neg: + (ne: + (match_operand:VDQ_I 1 "register_operand" "w") + (match_operand:VDQ_I 2 "aarch64_simd_imm_zero")))) + ] + "TARGET_SIMD" + "cmtst\t%0, %1, %1" + [(set_attr "type" "neon_tst")] +) + ;; One can also get a cmtsts by having to combine a ;; not (neq (eq x 0)) in which case you rewrite it to ;; a comparison against itself