From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id 5DE8A3947433 for ; Thu, 19 Mar 2020 06:48:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5DE8A3947433 Received: by mail-pf1-x444.google.com with SMTP id l184so897230pfl.7 for ; Wed, 18 Mar 2020 23:48:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4QgXQL3PqRUorijaJCrC40l41W3V2xpq2D6dyjgjZAs=; b=A8W8Mvm/gtYAptELqSu8QJQ0DM/WAJCQ60tzGiQKVZyYWlXETfCFzhr0KdGgfayAAD zl0vf0FEIbUq18jtEAm6obaLYMBLgu5Iy2k32u6cFjFB1jh0QO1jJn4FGKu1kld7osiN Vj8aFJPQR4DmXseIZBCTnTtnUIpue3pOGmLrpqJK3QbJ/SEEwrFXLyGzm1qSbLrXv2IT +NOLX6qX52Ixb1jeDLLsM+RO6b2AgmdkemyuZGny4wPPmep3Neq1UtUkzOEb6w/PP4XD WmPcLoDruFPN7U9N0DIhvZOZZWHvTa3nO2Fwha7sTqzJkXy0YZwQPK6nKr/RibQd7ndr iL8g== X-Gm-Message-State: ANhLgQ2y82zJ+XJZ8d5VQQS/tRVy01fjvin10tK5oPOP9UTUoJkpfT3Q pPbvSotOqj7I9CW7K/mDmDo1YEM20qI= X-Google-Smtp-Source: ADFU+vualW2QQId4saPU1uA3tnDVj7lsKwH9hPnW7iNXShuer839Vqt8peSS3HAgwqcYuVeFTQXfLA== X-Received: by 2002:aa7:9433:: with SMTP id y19mr2377467pfo.233.1584600492949; Wed, 18 Mar 2020 23:48:12 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id kb18sm1028081pjb.14.2020.03.18.23.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 23:48:12 -0700 (PDT) From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: richard.earnshaw@arm.com, richard.sandiford@arm.com, marcus.shawcroft@arm.com, kyrylo.tkachov@arm.com Subject: [PATCH 5/6] aarch64: Improve nzcv argument to ccmp Date: Wed, 18 Mar 2020 23:48:04 -0700 Message-Id: <20200319064805.17739-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200319064805.17739-1-richard.henderson@linaro.org> References: <20200319064805.17739-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.2 required=5.0 tests=DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 06:48:15 -0000 Currently we use %k to interpret an aarch64_cond_code value. This interpretation is done via an array, aarch64_nzcv_codes. The rtl is neither hindered nor harmed by using the proper nzcv value itself, so index the array earlier than later. This makes it easier to compare the rtl to the assembly. It is slightly confusing in that aarch64_nzcv_codes has values of nzcv which produce the inverse of the code that is the index. Invert those values. * config/aarch64/aarch64.c (AARCH64_CC_{NZCV}): Move up. (aarch64_nzcv_codes): Move up; reverse values of even/odd entries. (aarch64_gen_compare_reg): Use aarch64_nzcv_codes in gen_ccmpccdi generation. (aarch64_print_operand): Remove case 'k'. (aarch64_gen_ccmp_next): Invert condition for !AND, remove inversion for AND; use aarch64_nzcv_codes. * config/aarch64/aarch64.md (*ccmpcc): Remove %k from all alternatives. (*ccmpcc_rev, *ccmp, *ccmp_rev): Likewise. --- gcc/config/aarch64/aarch64.c | 81 +++++++++++++++-------------------- gcc/config/aarch64/aarch64.md | 16 +++---- 2 files changed, 42 insertions(+), 55 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 16ff40fc267..d7899dad759 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1270,6 +1270,36 @@ aarch64_cc; #define AARCH64_INVERSE_CONDITION_CODE(X) ((aarch64_cc) (((int) X) ^ 1)) +/* N Z C V. */ +#define AARCH64_CC_V 1 +#define AARCH64_CC_C (1 << 1) +#define AARCH64_CC_Z (1 << 2) +#define AARCH64_CC_N (1 << 3) + +/* + * N Z C V flags for ccmp. Indexed by aarch64_cond_code. + * These are the flags to make the given code be *true*. + */ +static const int aarch64_nzcv_codes[] = +{ + AARCH64_CC_Z, /* EQ, Z == 1. */ + 0, /* NE, Z == 0. */ + AARCH64_CC_C, /* CS, C == 1. */ + 0, /* CC, C == 0. */ + AARCH64_CC_N, /* MI, N == 1. */ + 0, /* PL, N == 0. */ + AARCH64_CC_V, /* VS, V == 1. */ + 0, /* VC, V == 0. */ + AARCH64_CC_C, /* HI, C == 1 && Z == 0. */ + 0, /* LS, !(C == 1 && Z == 0). */ + 0, /* GE, N == V. */ + AARCH64_CC_V, /* LT, N != V. */ + 0, /* GT, Z == 0 && N == V. */ + AARCH64_CC_V, /* LE, !(Z == 0 && N == V). */ + 0, /* AL, Any. */ + 0 /* NV, Any. */ +}; + struct aarch64_branch_protect_type { /* The type's name that the user passes to the branch-protection option @@ -2351,7 +2381,7 @@ aarch64_gen_compare_reg (RTX_CODE code, rtx x, rtx y) rtx y_hi = operand_subword (y, 1, 0, TImode); emit_insn (gen_ccmpccdi (cc_reg, x_hi, y_hi, gen_rtx_EQ (cc_mode, cc_reg, const0_rtx), - GEN_INT (AARCH64_EQ))); + GEN_INT (aarch64_nzcv_codes[AARCH64_NE]))); } else { @@ -9302,33 +9332,6 @@ aarch64_const_vec_all_in_range_p (rtx vec, return true; } -/* N Z C V. */ -#define AARCH64_CC_V 1 -#define AARCH64_CC_C (1 << 1) -#define AARCH64_CC_Z (1 << 2) -#define AARCH64_CC_N (1 << 3) - -/* N Z C V flags for ccmp. Indexed by AARCH64_COND_CODE. */ -static const int aarch64_nzcv_codes[] = -{ - 0, /* EQ, Z == 1. */ - AARCH64_CC_Z, /* NE, Z == 0. */ - 0, /* CS, C == 1. */ - AARCH64_CC_C, /* CC, C == 0. */ - 0, /* MI, N == 1. */ - AARCH64_CC_N, /* PL, N == 0. */ - 0, /* VS, V == 1. */ - AARCH64_CC_V, /* VC, V == 0. */ - 0, /* HI, C ==1 && Z == 0. */ - AARCH64_CC_C, /* LS, !(C == 1 && Z == 0). */ - AARCH64_CC_V, /* GE, N == V. */ - 0, /* LT, N != V. */ - AARCH64_CC_Z, /* GT, Z == 0 && N == V. */ - 0, /* LE, !(Z == 0 && N == V). */ - 0, /* AL, Any. */ - 0 /* NV, Any. */ -}; - /* Print floating-point vector immediate operand X to F, negating it first if NEGATE is true. Return true on success, false if it isn't a constant we can handle. */ @@ -9416,7 +9419,6 @@ sizetochar (int size) (32-bit or 64-bit). '0': Print a normal operand, if it's a general register, then we assume DImode. - 'k': Print NZCV for conditional compare instructions. 'A': Output address constant representing the first argument of X, specifying a relocation offset if appropriate. @@ -9866,22 +9868,6 @@ aarch64_print_operand (FILE *f, rtx x, int code) output_addr_const (asm_out_file, x); break; - case 'k': - { - HOST_WIDE_INT cond_code; - - if (!CONST_INT_P (x)) - { - output_operand_lossage ("invalid operand for '%%%c'", code); - return; - } - - cond_code = INTVAL (x); - gcc_assert (cond_code >= 0 && cond_code <= AARCH64_NV); - asm_fprintf (f, "%d", aarch64_nzcv_codes[cond_code]); - } - break; - case 'y': case 'z': { @@ -20514,14 +20500,15 @@ aarch64_gen_ccmp_next (rtx_insn **prep_seq, rtx_insn **gen_seq, rtx prev, rtx_code code = reverse_condition (prev_code); prev = gen_rtx_fmt_ee (code, VOIDmode, XEXP (prev, 0), const0_rtx); } - aarch64_cond = AARCH64_INVERSE_CONDITION_CODE (aarch64_cond); } + else + aarch64_cond = AARCH64_INVERSE_CONDITION_CODE (aarch64_cond); create_fixed_operand (&ops[0], target); create_fixed_operand (&ops[1], op0); create_fixed_operand (&ops[2], op1); create_fixed_operand (&ops[3], prev); - create_fixed_operand (&ops[4], GEN_INT (aarch64_cond)); + create_fixed_operand (&ops[4], GEN_INT (aarch64_nzcv_codes[aarch64_cond])); push_to_sequence (*gen_seq); if (!maybe_expand_insn (icode, 5, ops)) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 12213176103..c789b641e7c 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -522,9 +522,9 @@ UNSPEC_NZCV)))] "" "@ - ccmp\\t%2, %3, %k5, %m4 - ccmp\\t%2, %3, %k5, %m4 - ccmn\\t%2, #%n3, %k5, %m4" + ccmp\\t%2, %3, %5, %m4 + ccmp\\t%2, %3, %5, %m4 + ccmn\\t%2, #%n3, %5, %m4" [(set_attr "type" "alus_sreg,alus_imm,alus_imm")] ) @@ -554,7 +554,7 @@ [(match_operand 5 "immediate_operand")] UNSPEC_NZCV)))] "TARGET_FLOAT" - "fccmp\\t%2, %3, %k5, %m4" + "fccmp\\t%2, %3, %5, %m4" [(set_attr "type" "fccmp")] ) @@ -585,9 +585,9 @@ (match_operand:GPI 3 "aarch64_ccmp_operand" "r,Uss,Usn"))))] "" "@ - ccmp\\t%2, %3, %k5, %M4 - ccmp\\t%2, %3, %k5, %M4 - ccmn\\t%2, #%n3, %k5, %M4" + ccmp\\t%2, %3, %5, %M4 + ccmp\\t%2, %3, %5, %M4 + ccmn\\t%2, #%n3, %5, %M4" [(set_attr "type" "alus_sreg,alus_imm,alus_imm")] ) @@ -617,7 +617,7 @@ (match_operand:GPF 2 "register_operand" "w") (match_operand:GPF 3 "register_operand" "w"))))] "TARGET_FLOAT" - "fccmp\\t%2, %3, %k5, %M4" + "fccmp\\t%2, %3, %5, %M4" [(set_attr "type" "fccmp")] ) -- 2.20.1