forked from devyte/esp-quick-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gcc: xtensa: Add some dedicated patterns that correspond to GIMPLE ca…
…nonicalizations 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.
- Loading branch information
1 parent
9354151
commit f8a6a20
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
patches/gcc10.3/gcc-xtensa-0025-Add-some-dedicated-patterns-that-correspond-t.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
From a518d39cac906cc6a6fecb74ebb9129c7c538aef Mon Sep 17 00:00:00 2001 | ||
From: Takayuki 'January June' Suwa <[email protected]> | ||
Date: Sun, 20 Feb 2022 17:20:31 +0900 | ||
Subject: [PATCH 19/19] xtensa: Add some dedicated patterns that correspond to | ||
GIMPLE canonicalizations | ||
|
||
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: | ||
|
||
* gcc/config/xtensa/xtensa.md (*round_up_to_even): | ||
New insn-and-split pattern. | ||
(*signed_ge_zero): Ditto. | ||
--- | ||
gcc/config/xtensa/xtensa.md | 44 +++++++++++++++++++++++++++++++++++++ | ||
1 file changed, 44 insertions(+) | ||
|
||
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md | ||
index 919268c54..100cf35fd 100644 | ||
--- a/gcc/config/xtensa/xtensa.md | ||
+++ b/gcc/config/xtensa/xtensa.md | ||
@@ -2593,3 +2593,47 @@ | ||
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))) | ||
+ (clobber (match_scratch:SI 2 "=&a"))] | ||
+ "" | ||
+ "#" | ||
+ "reload_completed" | ||
+ [(set (match_dup 2) | ||
+ (and:SI (match_dup 1) | ||
+ (const_int 1))) | ||
+ (set (match_dup 0) | ||
+ (plus:SI (match_dup 2) | ||
+ (match_dup 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)))]) | ||
+ | ||
+(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 | ||
|