From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1880) id 408CF3858D35; Wed, 18 Jan 2023 10:29:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 408CF3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674037742; bh=WIxRf+d6sfDLmxjU/vYdHz/i+bBifg1a4cdKq5XNieM=; h=From:To:Subject:Date:From; b=UVkfduwGI34evwDq3Vbp2vK7WdtFLUQRXk+tK3552PLwiugVYMiXSACUvc/qslbgh F7qsqLRSm16WufbIzD1AqxNWaNqiWSO4s9HxKCnlObdG6AUWweW01LlchZK7dg/0VK S5Rbh94VqIQtZmrmwUT2uu5ZWGYKgVAY5YY/B9wU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Max Filippov To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5238] xtensa: Optimize inversion of the MSB X-Act-Checkin: gcc X-Git-Author: Takayuki 'January June' Suwa X-Git-Refname: refs/heads/master X-Git-Oldrev: aaf29ae6cdbaad58b709a77784375d15138174b3 X-Git-Newrev: a4b05944b7d409682197a9f50759a4ed97145e23 Message-Id: <20230118102902.408CF3858D35@sourceware.org> Date: Wed, 18 Jan 2023 10:29:02 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a4b05944b7d409682197a9f50759a4ed97145e23 commit r13-5238-ga4b05944b7d409682197a9f50759a4ed97145e23 Author: Takayuki 'January June' Suwa Date: Wed Jan 18 14:43:13 2023 +0900 xtensa: Optimize inversion of the MSB Such operation can be done either bitwise-XOR or addition with -2147483648, but the latter is one byte less if TARGET_DENSITY. gcc/ChangeLog: * config/xtensa/xtensa.md (xorsi3_internal): Rename from the original of "xorsi3". (xorsi3): New expansion pattern that emits addition rather than bitwise-XOR when the second source is a constant of -2147483648 if TARGET_DENSITY. Diff: --- gcc/config/xtensa/xtensa.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md index 98f3c468f8b..dd3fc37353b 100644 --- a/gcc/config/xtensa/xtensa.md +++ b/gcc/config/xtensa/xtensa.md @@ -736,7 +736,31 @@ (set_attr "mode" "SI") (set_attr "length" "3")]) -(define_insn "xorsi3" +(define_expand "xorsi3" + [(set (match_operand:SI 0 "register_operand") + (xor:SI (match_operand:SI 1 "register_operand") + (match_operand:SI 2 "nonmemory_operand")))] + "" +{ + if (register_operand (operands[2], SImode)) + emit_insn (gen_xorsi3_internal (operands[0], operands[1], + operands[2])); + else + { + rtx (*gen_op)(rtx, rtx, rtx); + if (TARGET_DENSITY + && CONST_INT_P (operands[2]) + && INTVAL (operands[2]) == -2147483648L) + gen_op = gen_addsi3; + else + gen_op = gen_xorsi3_internal; + emit_insn (gen_op (operands[0], operands[1], + force_reg (SImode, operands[2]))); + } + DONE; +}) + +(define_insn "xorsi3_internal" [(set (match_operand:SI 0 "register_operand" "=a") (xor:SI (match_operand:SI 1 "register_operand" "%r") (match_operand:SI 2 "register_operand" "r")))]