* [PATCH 3/5] xtensa: Add some dedicated patterns that correspond to GIMPLE canonicalizations
@ 2022-06-14 3:37 Takayuki 'January June' Suwa
2022-06-16 0:01 ` Max Filippov
0 siblings, 1 reply; 2+ messages in thread
From: Takayuki 'January June' Suwa @ 2022-06-14 3:37 UTC (permalink / raw)
To: GCC Patches
This patch offers better RTL representations against straightforward
derivations from some tree optimizers' canonicalized forms.
- rounding up to even, such as '(x + (x & 1))', is canonicalized to
'((x + 1) & -2)', but the former is one instruction less than the latter
in Xtensa ISA.
- signed greater or equal to zero as logical value '((signed)x >= 0)',
is canonicalized to '((unsigned)(x ^ -1) >> 31)', but the equivalent
'(((signed)x >> 31) + 1)' is one instruction less.
gcc/ChangeLog:
* config/xtensa/xtensa.md (*round_up_to_even):
New insn-and-split pattern.
(*signed_ge_zero): Ditto.
---
gcc/config/xtensa/xtensa.md | 45 +++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 181f935e3c3..9588a829136 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -2679,3 +2679,48 @@
xtensa_expand_atomic (<CODE>, operands[0], operands[1], operands[2], true);
DONE;
})
+
+(define_insn_and_split "*round_up_to_even"
+ [(set (match_operand:SI 0 "register_operand" "=a")
+ (and:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
+ (const_int 1))
+ (const_int -2)))]
+ ""
+ "#"
+ "can_create_pseudo_p ()"
+ [(set (match_dup 2)
+ (and:SI (match_dup 1)
+ (const_int 1)))
+ (set (match_dup 0)
+ (plus:SI (match_dup 2)
+ (match_dup 1)))]
+{
+ operands[2] = gen_reg_rtx (SImode);
+}
+ [(set_attr "type" "arith")
+ (set_attr "mode" "SI")
+ (set (attr "length")
+ (if_then_else (match_test "TARGET_DENSITY")
+ (const_int 5)
+ (const_int 6)))])
+
+(define_insn_and_split "*signed_ge_zero"
+ [(set (match_operand:SI 0 "register_operand" "=a")
+ (ge:SI (match_operand:SI 1 "register_operand" "r")
+ (const_int 0)))]
+ ""
+ "#"
+ ""
+ [(set (match_dup 0)
+ (ashiftrt:SI (match_dup 1)
+ (const_int 31)))
+ (set (match_dup 0)
+ (plus:SI (match_dup 0)
+ (const_int 1)))]
+ ""
+ [(set_attr "type" "arith")
+ (set_attr "mode" "SI")
+ (set (attr "length")
+ (if_then_else (match_test "TARGET_DENSITY")
+ (const_int 5)
+ (const_int 6)))])
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/5] xtensa: Add some dedicated patterns that correspond to GIMPLE canonicalizations
2022-06-14 3:37 [PATCH 3/5] xtensa: Add some dedicated patterns that correspond to GIMPLE canonicalizations Takayuki 'January June' Suwa
@ 2022-06-16 0:01 ` Max Filippov
0 siblings, 0 replies; 2+ messages in thread
From: Max Filippov @ 2022-06-16 0:01 UTC (permalink / raw)
To: Takayuki 'January June' Suwa; +Cc: GCC Patches
On Mon, Jun 13, 2022 at 8:54 PM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> This patch offers better RTL representations against straightforward
> derivations from some tree optimizers' canonicalized forms.
>
> - rounding up to even, such as '(x + (x & 1))', is canonicalized to
> '((x + 1) & -2)', but the former is one instruction less than the latter
> in Xtensa ISA.
> - signed greater or equal to zero as logical value '((signed)x >= 0)',
> is canonicalized to '((unsigned)(x ^ -1) >> 31)', but the equivalent
> '(((signed)x >> 31) + 1)' is one instruction less.
>
> gcc/ChangeLog:
>
> * config/xtensa/xtensa.md (*round_up_to_even):
> New insn-and-split pattern.
> (*signed_ge_zero): Ditto.
> ---
> gcc/config/xtensa/xtensa.md | 45 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
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:[~2022-06-16 0:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 3:37 [PATCH 3/5] xtensa: Add some dedicated patterns that correspond to GIMPLE canonicalizations Takayuki 'January June' Suwa
2022-06-16 0:01 ` 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).