public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] xtensa: Tune "*btrue" insn pattern
       [not found] <92692f27-76e3-ce45-bc25-95b9a7d2b64f.ref@yahoo.co.jp>
@ 2023-01-12  4:25 ` Takayuki 'January June' Suwa
  2023-01-12 12:46   ` Max Filippov
  0 siblings, 1 reply; 2+ messages in thread
From: Takayuki 'January June' Suwa @ 2023-01-12  4:25 UTC (permalink / raw)
  To: GCC Patches; +Cc: Max Filippov

This branch instruction has short encoding if EQ/NE comparison against
immediate zero when the Code Density Option is enabled, but its "length"
attribute was only for normal encoding.  This patch fixes it.

This patch also prevents undesireable replacement the comparison immediate
zero of the instruction (short encoding, as mentioned above) with a
register that has value of zero (normal encoding) by the postreload pass.

gcc/ChangeLog:

	* config/xtensa/xtensa.md (*btrue):
	Correct value of the attribute "length" that depends on
	TARGET_DENSITY and operands, and add '?' character to the register
	constraint of the compared operand.
---
 gcc/config/xtensa/xtensa.md | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index db1d68ee658..b4989832169 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -1679,7 +1679,7 @@
   [(set (pc)
 	(if_then_else (match_operator 3 "branch_operator"
 			[(match_operand:SI 0 "register_operand" "r,r")
-			 (match_operand:SI 1 "branch_operand" "K,r")])
+			 (match_operand:SI 1 "branch_operand" "K,?r")])
 		      (label_ref (match_operand 2 "" ""))
 		      (pc)))]
   ""
@@ -1688,7 +1688,14 @@
 }
   [(set_attr "type"	"jump,jump")
    (set_attr "mode"	"none")
-   (set_attr "length"	"3,3")])
+   (set (attr "length")
+        (if_then_else (match_test "TARGET_DENSITY
+				   && CONST_INT_P (operands[1])
+				   && INTVAL (operands[1]) == 0
+				   && (GET_CODE (operands[3]) == EQ
+				       || GET_CODE (operands[3]) == NE)")
+                      (const_int 2)
+                      (const_int 3)))])
 
 (define_insn "*ubtrue"
   [(set (pc)
-- 
2.30.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] xtensa: Tune "*btrue" insn pattern
  2023-01-12  4:25 ` [PATCH 1/2] xtensa: Tune "*btrue" insn pattern Takayuki 'January June' Suwa
@ 2023-01-12 12:46   ` Max Filippov
  0 siblings, 0 replies; 2+ messages in thread
From: Max Filippov @ 2023-01-12 12:46 UTC (permalink / raw)
  To: Takayuki 'January June' Suwa; +Cc: GCC Patches

On Wed, Jan 11, 2023 at 8:26 PM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> This branch instruction has short encoding if EQ/NE comparison against
> immediate zero when the Code Density Option is enabled, but its "length"
> attribute was only for normal encoding.  This patch fixes it.
>
> This patch also prevents undesireable replacement the comparison immediate
> zero of the instruction (short encoding, as mentioned above) with a
> register that has value of zero (normal encoding) by the postreload pass.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.md (*btrue):
>         Correct value of the attribute "length" that depends on
>         TARGET_DENSITY and operands, and add '?' character to the register
>         constraint of the compared operand.
> ---
>  gcc/config/xtensa/xtensa.md | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-12 12:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <92692f27-76e3-ce45-bc25-95b9a7d2b64f.ref@yahoo.co.jp>
2023-01-12  4:25 ` [PATCH 1/2] xtensa: Tune "*btrue" insn pattern Takayuki 'January June' Suwa
2023-01-12 12:46   ` Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).