forked from earlephilhower/esp-quick-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gcc: xtensa: Backport patches from upstream/master (v3)
List of patches added after earlephilhower#37: 461d3c84a0e5ad045ee54631901cc953d6befa20 "xtensa: fix PR target/108919" ce83c3e492c2fa5a08c15b5f4619d58f42a5dcd0 "xtensa: Make use of CLAMPS instruction if configured" c981f61c071757f1f724fe7c3959622c13f079fa "xtensa: Remove REG_OK_STRICT and its derivatives" 675b1a7f113adb1d737adaf78b4fd90be7a0ed1a "ifcvt.c: Prevent excessive if-conversion for conditional moves" e33d2dcb463161a110ac345a451132ce8b2b23d9 "xtensa: Optimize '(x & CST1_POW2) != 0 ? CST2_POW2 : 0'" 8a20b4bc50bdc8d61610974d60d5851f3fd8b70f "xtensa: Merge '*addx' and '*subx' insn patterns into one" bf78e24a90d4d064b0372a03c0327b6f90475949 "xtensa: tidy extzvsi-1bit patterns" 9b867c8281ee313cf6ec737d8f4a9ba7ef78408e "xtensa: Add 'subtraction from constant' insn pattern" 78648c09a0494e6bf1edbd97acb708bc282eb5f5 "xtensa: Rework 'setmemsi' insn pattern" feae4e83f76cf8e6698429d5acb08ff1968d13f2 "xtensa: Improve "*shlrd_reg" insn pattern and its variant" fe3ce0861081dd17e581c32b299b9c743d000470 "xtensa: Add 'adddi3' and 'subdi3' insn patterns" 830d36b3c307c70af57b832821d8590b29a5bda5 "xtensa: Optimize boolean evaluation or branching when EQ/NE to INT_MIN" 1ce54ad8cd694a1defb9374f18607194ef702ea7 "xtensa: Remove TARGET_MEMORY_MOVE_COST hook" 7360cba833cd921631818428a851e03ea88f1e8a "xtensa: constantsynth: Add new 2-insns synthesis pattern" 0778f4dcdafa7dabb015a3375089addc1a4df49b "xtensa: Fix missing mode warning in "*eqne_INT_MIN"" 2f615b33dd61590a74e7758e19016250ade2b828 "xtensa: The use of CLAMPS instruction also requires TARGET_MINMAX, as well as TARGET_CLAMPS" cd22b97726472138d3fe22fb1ff0c27176408fc9 "xtensa: Use HARD_REG_SET instead of bare integer" a4829dda6362f5f653c4bd5783374fafc0e8622f "xtensa: Optimize boolean evaluation when SImode EQ/NE to zero if TARGET_MINMAX" 1d17d58c284fa8c30a42195dadd14a44606c987e "xtensa: Optimize several boolean evaluations of EQ/NE against constant zero" fd948fd846c7de29150872e43b63bf9128da5b8f "xtensa: use salt/saltu in xtensa_expand_scc" cc7aca846ae524f36a350cd54cd31da22acd6805 "xtensa: fix salt/saltu version check" 3f722e7886ff46385033d9187e21f49c523083d4 "xtensa: Fix missing mode warning in "*eqne_zero_masked_bits"" 24d5e0bf19f27a89a13f64b4b8750dbde89bdaa0 "xtensa: Make full transition to LRA" 7c2c7dd24bd93cd9cb8a6e54a4d11850982665fd "xtensa: Recover constant synthesis for HImode after LRA transition" bc5a9dab55d13f888a3cdd150c8cf5c2244f35e0 "xtensa: reorder movsi_internal patterns for better code generation during LRA"
- Loading branch information
1 parent
1cd2ab4
commit 43d6a13
Showing
75 changed files
with
9,714 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
patches/gcc10.1/gcc-Prevent-excessive-if-conversion-for-conditio.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,30 @@ | ||
From 2f809e6054945c82ed30c11d605080897f88a6e6 Mon Sep 17 00:00:00 2001 | ||
From: Takayuki 'January June' Suwa <[email protected]> | ||
Date: Tue, 18 Apr 2023 14:11:09 -0600 | ||
Subject: [PATCH 01/19] ifcvt.c: Prevent excessive if-conversion for | ||
conditional moves | ||
|
||
gcc/ | ||
* ifcvt.c (cond_move_process_if_block): Consider the result of | ||
targetm.noce_conversion_profitable_p() when replacing the original | ||
sequence with the converted one. | ||
--- | ||
gcc/ifcvt.c | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c | ||
index 977dd1bd4..c1aab7dd2 100644 | ||
--- a/gcc/ifcvt.c | ||
+++ b/gcc/ifcvt.c | ||
@@ -3963,7 +3963,7 @@ cond_move_process_if_block (struct noce_if_info *if_info) | ||
goto done; | ||
} | ||
seq = end_ifcvt_sequence (if_info); | ||
- if (!seq) | ||
+ if (!seq || !targetm.noce_conversion_profitable_p (seq, if_info)) | ||
goto done; | ||
|
||
loc_insn = first_active_insn (then_bb); | ||
-- | ||
2.30.2 | ||
|
184 changes: 184 additions & 0 deletions
184
patches/gcc10.1/gcc-xtensa-0078-fix-PR-target-108919.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,184 @@ | ||
From 15990e92b92f65aa5951d1f53d39d15cbde6c0cd Mon Sep 17 00:00:00 2001 | ||
From: Max Filippov <[email protected]> | ||
Date: Wed, 22 Feb 2023 14:17:11 -0800 | ||
Subject: [PATCH] gcc: xtensa: fix PR target/108919 | ||
|
||
gcc/ | ||
PR target/108919 | ||
|
||
* config/xtensa/xtensa-protos.h | ||
(xtensa_prepare_expand_call): Rename to xtensa_expand_call. | ||
* config/xtensa/xtensa.c (xtensa_prepare_expand_call): Rename | ||
to xtensa_expand_call. | ||
(xtensa_expand_call): Emit the call and add a clobber expression | ||
for the static chain to it in case of windowed ABI. | ||
* config/xtensa/xtensa.md (call, call_value, sibcall) | ||
(sibcall_value): Call xtensa_expand_call and complete expansion | ||
right after that call. | ||
|
||
gcc/testsuite/ | ||
* gcc.target/xtensa/pr108919.c: New test. | ||
--- | ||
gcc/config/xtensa/xtensa-protos.h | 2 +- | ||
gcc/config/xtensa/xtensa.c | 25 +++++++++++- | ||
gcc/config/xtensa/xtensa.md | 12 ++++-- | ||
gcc/testsuite/gcc.target/xtensa/pr108919.c | 46 ++++++++++++++++++++++ | ||
4 files changed, 79 insertions(+), 6 deletions(-) | ||
create mode 100644 gcc/testsuite/gcc.target/xtensa/pr108919.c | ||
|
||
diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h | ||
index 39d5a5825..74a5d93a0 100644 | ||
--- a/gcc/config/xtensa/xtensa-protos.h | ||
+++ b/gcc/config/xtensa/xtensa-protos.h | ||
@@ -53,7 +53,7 @@ extern void xtensa_expand_atomic (enum rtx_code, rtx, rtx, rtx, bool); | ||
extern void xtensa_emit_loop_end (rtx_insn *, rtx *); | ||
extern char *xtensa_emit_branch (bool, rtx *); | ||
extern char *xtensa_emit_movcc (bool, bool, bool, rtx *); | ||
-extern void xtensa_prepare_expand_call (int, rtx *); | ||
+extern void xtensa_expand_call (int, rtx *); | ||
extern char *xtensa_emit_call (int, rtx *); | ||
extern char *xtensa_emit_sibcall (int, rtx *); | ||
extern bool xtensa_tls_referenced_p (rtx); | ||
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c | ||
index 6aea625d9..1e0820d4f 100644 | ||
--- a/gcc/config/xtensa/xtensa.c | ||
+++ b/gcc/config/xtensa/xtensa.c | ||
@@ -2173,8 +2173,10 @@ xtensa_emit_movcc (bool inverted, bool isfp, bool isbool, rtx *operands) | ||
|
||
|
||
void | ||
-xtensa_prepare_expand_call (int callop, rtx *operands) | ||
+xtensa_expand_call (int callop, rtx *operands) | ||
{ | ||
+ rtx call; | ||
+ rtx_insn *call_insn; | ||
rtx addr = XEXP (operands[callop], 0); | ||
|
||
if (flag_pic && SYMBOL_REF_P (addr) | ||
@@ -2192,6 +2194,27 @@ xtensa_prepare_expand_call (int callop, rtx *operands) | ||
Pmode); | ||
XEXP (operands[callop], 0) = reg; | ||
} | ||
+ | ||
+ call = gen_rtx_CALL (VOIDmode, operands[callop], operands[callop + 1]); | ||
+ | ||
+ if (callop) | ||
+ call = gen_rtx_SET (operands[0], call); | ||
+ | ||
+ call_insn = emit_call_insn (call); | ||
+ | ||
+ if (TARGET_WINDOWED_ABI) | ||
+ { | ||
+ /* | ||
+ * Windowed xtensa ABI specifies that static chain pointer is passed | ||
+ * in memory below the caller's stack pointer, which means that the | ||
+ * callee may clobber it if it's a non-leaf function. | ||
+ * Add the clobber expression for the static chain to the function call | ||
+ * expression list so that it is not assumed to be live across the call. | ||
+ */ | ||
+ rtx clob = gen_rtx_CLOBBER (Pmode, xtensa_static_chain (NULL, false)); | ||
+ CALL_INSN_FUNCTION_USAGE (call_insn) = | ||
+ gen_rtx_EXPR_LIST (Pmode, clob, CALL_INSN_FUNCTION_USAGE (call_insn)); | ||
+ } | ||
} | ||
|
||
|
||
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md | ||
index 628b27b32..30e4022ca 100644 | ||
--- a/gcc/config/xtensa/xtensa.md | ||
+++ b/gcc/config/xtensa/xtensa.md | ||
@@ -2338,7 +2338,8 @@ | ||
(match_operand 1 "" ""))] | ||
"" | ||
{ | ||
- xtensa_prepare_expand_call (0, operands); | ||
+ xtensa_expand_call (0, operands); | ||
+ DONE; | ||
}) | ||
|
||
(define_insn "call_internal" | ||
@@ -2358,7 +2359,8 @@ | ||
(match_operand 2 "" "")))] | ||
"" | ||
{ | ||
- xtensa_prepare_expand_call (1, operands); | ||
+ xtensa_expand_call (1, operands); | ||
+ DONE; | ||
}) | ||
|
||
(define_insn "call_value_internal" | ||
@@ -2378,7 +2380,8 @@ | ||
(match_operand 1 "" ""))] | ||
"!TARGET_WINDOWED_ABI" | ||
{ | ||
- xtensa_prepare_expand_call (0, operands); | ||
+ xtensa_expand_call (0, operands); | ||
+ DONE; | ||
}) | ||
|
||
(define_insn "sibcall_internal" | ||
@@ -2398,7 +2401,8 @@ | ||
(match_operand 2 "" "")))] | ||
"!TARGET_WINDOWED_ABI" | ||
{ | ||
- xtensa_prepare_expand_call (1, operands); | ||
+ xtensa_expand_call (1, operands); | ||
+ DONE; | ||
}) | ||
|
||
(define_insn "sibcall_value_internal" | ||
diff --git a/gcc/testsuite/gcc.target/xtensa/pr108919.c b/gcc/testsuite/gcc.target/xtensa/pr108919.c | ||
new file mode 100644 | ||
index 000000000..300b6fd10 | ||
--- /dev/null | ||
+++ b/gcc/testsuite/gcc.target/xtensa/pr108919.c | ||
@@ -0,0 +1,46 @@ | ||
+/* { dg-do run } */ | ||
+/* { dg-options "-O2" } */ | ||
+ | ||
+ | ||
+#ifdef __XTENSA_CALL0_ABI__ | ||
+void __xtensa_libgcc_window_spill (void) | ||
+{ | ||
+} | ||
+#else | ||
+void __xtensa_libgcc_window_spill (void); | ||
+#endif | ||
+ | ||
+__attribute__((noinline)) void h (void) | ||
+{ | ||
+ __xtensa_libgcc_window_spill (); | ||
+} | ||
+ | ||
+int f (int u, int v) | ||
+{ | ||
+ int a = u; | ||
+ int s; | ||
+ | ||
+ __attribute__((noinline,pure)) int nested1 (int b) | ||
+ { | ||
+ h(); | ||
+ return a + b; | ||
+ } | ||
+ | ||
+ __attribute__((noinline,pure)) int nested2 (int b) | ||
+ { | ||
+ h(); | ||
+ return a - b; | ||
+ } | ||
+ | ||
+ s = nested1 (v); | ||
+ s += nested2 (v); | ||
+ return s; | ||
+} | ||
+ | ||
+int main (void) | ||
+{ | ||
+ int u = 0x12345678; | ||
+ int v = 1; | ||
+ | ||
+ return f (u, v) == 2 * u ? 0 : 1; | ||
+} | ||
-- | ||
2.30.2 | ||
|
136 changes: 136 additions & 0 deletions
136
patches/gcc10.1/gcc-xtensa-0079-Make-use-of-CLAMPS-instruction-if-configured.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,136 @@ | ||
From e0a5a834dc034c239ae7f319d0287fb24db13744 Mon Sep 17 00:00:00 2001 | ||
From: Takayuki 'January June' Suwa <[email protected]> | ||
Date: Mon, 27 Feb 2023 02:27:42 +0900 | ||
Subject: [PATCH] xtensa: Make use of CLAMPS instruction if configured | ||
|
||
This patch introduces the use of CLAMPS instruction when the instruction | ||
is configured. | ||
|
||
/* example */ | ||
int test(int a) { | ||
if (a < -512) | ||
return -512; | ||
if (a > 511) | ||
return 511; | ||
return a; | ||
} | ||
|
||
;; prereq: TARGET_CLAMPS | ||
test: | ||
clamps a2, a2, 9 | ||
ret.n | ||
|
||
gcc/ChangeLog: | ||
|
||
* config/xtensa/xtensa-protos.h (xtensa_match_CLAMPS_imms_p): | ||
New prototype. | ||
* config/xtensa/xtensa.c (xtensa_match_CLAMPS_imms_p): | ||
New function. | ||
* config/xtensa/xtensa.h (TARGET_CLAMPS): New macro definition. | ||
* config/xtensa/xtensa.md (*xtensa_clamps): New insn pattern. | ||
--- | ||
gcc/config/xtensa/xtensa-protos.h | 1 + | ||
gcc/config/xtensa/xtensa.c | 13 +++++++++++ | ||
gcc/config/xtensa/xtensa.h | 1 + | ||
gcc/config/xtensa/xtensa.md | 37 +++++++++++++++++++++++++++++++ | ||
4 files changed, 52 insertions(+) | ||
|
||
diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h | ||
index 74a5d93a0..59e5cd1bb 100644 | ||
--- a/gcc/config/xtensa/xtensa-protos.h | ||
+++ b/gcc/config/xtensa/xtensa-protos.h | ||
@@ -60,6 +60,7 @@ extern bool xtensa_tls_referenced_p (rtx); | ||
extern enum rtx_code xtensa_shlrd_which_direction (rtx, rtx); | ||
extern bool xtensa_split1_finished_p (void); | ||
extern void xtensa_split_DI_reg_imm (rtx *); | ||
+extern bool xtensa_match_CLAMPS_imms_p (rtx, rtx); | ||
|
||
#ifdef TREE_CODE | ||
extern void init_cumulative_args (CUMULATIVE_ARGS *, int); | ||
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c | ||
index 1e0820d4f..a62665d6b 100644 | ||
--- a/gcc/config/xtensa/xtensa.c | ||
+++ b/gcc/config/xtensa/xtensa.c | ||
@@ -2602,6 +2602,19 @@ xtensa_emit_add_imm (rtx dst, rtx src, HOST_WIDE_INT imm, rtx scratch, | ||
} | ||
|
||
|
||
+/* Return true if the constants used in the application of smin() following | ||
+ smax() meet the specifications of the CLAMPS machine instruction. */ | ||
+bool | ||
+xtensa_match_CLAMPS_imms_p (rtx cst_max, rtx cst_min) | ||
+{ | ||
+ int max, min; | ||
+ | ||
+ return IN_RANGE (max = exact_log2 (-INTVAL (cst_max)), 7, 22) | ||
+ && IN_RANGE (min = exact_log2 (INTVAL (cst_min) + 1), 7, 22) | ||
+ && max == min; | ||
+} | ||
+ | ||
+ | ||
/* Implement TARGET_CANNOT_FORCE_CONST_MEM. */ | ||
|
||
static bool | ||
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h | ||
index ef7f9e5d5..19d35f20a 100644 | ||
--- a/gcc/config/xtensa/xtensa.h | ||
+++ b/gcc/config/xtensa/xtensa.h | ||
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see | ||
#define TARGET_NSA XCHAL_HAVE_NSA | ||
#define TARGET_MINMAX XCHAL_HAVE_MINMAX | ||
#define TARGET_SEXT XCHAL_HAVE_SEXT | ||
+#define TARGET_CLAMPS XCHAL_HAVE_CLAMPS | ||
#define TARGET_BOOLEANS XCHAL_HAVE_BOOLEANS | ||
#define TARGET_HARD_FLOAT XCHAL_HAVE_FP | ||
#define TARGET_HARD_FLOAT_DIV XCHAL_HAVE_FP_DIV | ||
diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md | ||
index 30e4022ca..8fd3e006a 100644 | ||
--- a/gcc/config/xtensa/xtensa.md | ||
+++ b/gcc/config/xtensa/xtensa.md | ||
@@ -446,6 +446,43 @@ | ||
(set_attr "mode" "SI") | ||
(set_attr "length" "3")]) | ||
|
||
+ | ||
+;; Signed clamp. | ||
+ | ||
+(define_insn_and_split "*xtensa_clamps" | ||
+ [(set (match_operand:SI 0 "register_operand" "=a") | ||
+ (smax:SI (smin:SI (match_operand:SI 1 "register_operand" "r") | ||
+ (match_operand:SI 2 "const_int_operand" "i")) | ||
+ (match_operand:SI 3 "const_int_operand" "i")))] | ||
+ "TARGET_CLAMPS | ||
+ && xtensa_match_CLAMPS_imms_p (operands[3], operands[2])" | ||
+ "#" | ||
+ "&& 1" | ||
+ [(set (match_dup 0) | ||
+ (smin:SI (smax:SI (match_dup 1) | ||
+ (match_dup 3)) | ||
+ (match_dup 2)))] | ||
+ "" | ||
+ [(set_attr "type" "arith") | ||
+ (set_attr "mode" "SI") | ||
+ (set_attr "length" "3")]) | ||
+ | ||
+(define_insn "*xtensa_clamps" | ||
+ [(set (match_operand:SI 0 "register_operand" "=a") | ||
+ (smin:SI (smax:SI (match_operand:SI 1 "register_operand" "r") | ||
+ (match_operand:SI 2 "const_int_operand" "i")) | ||
+ (match_operand:SI 3 "const_int_operand" "i")))] | ||
+ "TARGET_CLAMPS | ||
+ && xtensa_match_CLAMPS_imms_p (operands[2], operands[3])" | ||
+{ | ||
+ static char result[64]; | ||
+ sprintf (result, "clamps\t%%0, %%1, %d", floor_log2 (-INTVAL (operands[2]))); | ||
+ return result; | ||
+} | ||
+ [(set_attr "type" "arith") | ||
+ (set_attr "mode" "SI") | ||
+ (set_attr "length" "3")]) | ||
+ | ||
|
||
;; Count redundant leading sign bits and leading/trailing zeros, | ||
;; and find first bit. | ||
-- | ||
2.30.2 | ||
|
44 changes: 44 additions & 0 deletions
44
patches/gcc10.1/gcc-xtensa-0080-Remove-REG_OK_STRICT-and-its-derivatives.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,44 @@ | ||
From f90cf6b4d8328a771cff1db3078ab2062cf95085 Mon Sep 17 00:00:00 2001 | ||
From: Takayuki 'January June' Suwa <[email protected]> | ||
Date: Sun, 12 Mar 2023 23:14:13 +0900 | ||
Subject: [PATCH] xtensa: Remove REG_OK_STRICT and its derivatives | ||
|
||
Because GO_IF_LEGITIMATE_ADDRESS was deprecated a long time ago | ||
(see commit c6c3dba931548987c78719180e30ebc863404b89). | ||
|
||
gcc/ChangeLog: | ||
|
||
* config/xtensa/xtensa.h (REG_OK_STRICT, REG_OK_FOR_INDEX_P, | ||
REG_OK_FOR_BASE_P): Remove. | ||
--- | ||
gcc/config/xtensa/xtensa.h | 11 +---------- | ||
1 file changed, 1 insertion(+), 10 deletions(-) | ||
|
||
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h | ||
index 19d35f20a..fb06b6141 100644 | ||
--- a/gcc/config/xtensa/xtensa.h | ||
+++ b/gcc/config/xtensa/xtensa.h | ||
@@ -591,19 +591,10 @@ typedef struct xtensa_args | ||
/* C expressions that are nonzero if X (assumed to be a `reg' RTX) is | ||
valid for use as a base or index register. */ | ||
|
||
-#ifdef REG_OK_STRICT | ||
-#define REG_OK_STRICT_FLAG 1 | ||
-#else | ||
-#define REG_OK_STRICT_FLAG 0 | ||
-#endif | ||
- | ||
#define BASE_REG_P(X, STRICT) \ | ||
- ((!(STRICT) && REGNO (X) >= FIRST_PSEUDO_REGISTER) \ | ||
+ ((!(STRICT) && ! HARD_REGISTER_P (X)) \ | ||
|| REGNO_OK_FOR_BASE_P (REGNO (X))) | ||
|
||
-#define REG_OK_FOR_INDEX_P(X) 0 | ||
-#define REG_OK_FOR_BASE_P(X) BASE_REG_P (X, REG_OK_STRICT_FLAG) | ||
- | ||
/* Maximum number of registers that can appear in a valid memory address. */ | ||
#define MAX_REGS_PER_ADDRESS 1 | ||
|
||
-- | ||
2.30.2 | ||
|
Oops, something went wrong.