summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSundeep KOKKONDA <sundeep.kokkonda@windriver.com>2025-05-22 21:49:35 -0700
committerSteve Sakoman <steve@sakoman.com>2025-05-28 08:46:32 -0700
commitc6cd61f1a22d04ba3241e00caf6f35cc2ca76da1 (patch)
treeb618f4d017df709d2d217123d4b224487aef62df
parentaee1d45a8333b6261e91f2c1278474f266346e61 (diff)
downloadpoky-c6cd61f1a22d04ba3241e00caf6f35cc2ca76da1.tar.gz
gcc: AArch64 - Fix strict-align cpymem/setmem
The cpymemdi/setmemdi implementation doesn't fully support strict alignment. Block the expansion if the alignment is less than 16 with STRICT_ALIGNMENT. Clean up the condition when to use MOPS. (PR103100) The original patch for GCC 12 removed MOPS & SIMD conditionals for setmem and cpymem expansions in aarch64.md file. However, this version for GCC 11 does not backport the SIMD & MOPS-related changes and retains the conditions in aarch64.md file to preserve correctness and compatibility with the GCC 11 backend. All changes and outputs have been verified by the author. Upstream-Status: Backport [https://gcc.gnu.org/cgit/gcc/commit/?id=b9d16d8361a9e3a82a2f21e759e760d235d43322] (From OE-Core rev: a99a65632116955dc69809a14bf536b22582de72) Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-devtools/gcc/gcc-11.5.inc1
-rw-r--r--meta/recipes-devtools/gcc/gcc/0032-gcc-aarch64-fix-strict-align-cpymem-setmem.patch45
2 files changed, 46 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-11.5.inc b/meta/recipes-devtools/gcc/gcc-11.5.inc
index f17ec9da5c..1e8371b2bd 100644
--- a/meta/recipes-devtools/gcc/gcc-11.5.inc
+++ b/meta/recipes-devtools/gcc/gcc-11.5.inc
@@ -60,6 +60,7 @@ SRC_URI = "\
60 file://0029-Fix-install-path-of-linux64.h.patch \ 60 file://0029-Fix-install-path-of-linux64.h.patch \
61 file://0030-rust-recursion-limit.patch \ 61 file://0030-rust-recursion-limit.patch \
62 file://0031-gcc-sanitizers-fix.patch \ 62 file://0031-gcc-sanitizers-fix.patch \
63 file://0032-gcc-aarch64-fix-strict-align-cpymem-setmem.patch \
63 file://0001-CVE-2021-42574.patch \ 64 file://0001-CVE-2021-42574.patch \
64 file://0002-CVE-2021-42574.patch \ 65 file://0002-CVE-2021-42574.patch \
65 file://0003-CVE-2021-42574.patch \ 66 file://0003-CVE-2021-42574.patch \
diff --git a/meta/recipes-devtools/gcc/gcc/0032-gcc-aarch64-fix-strict-align-cpymem-setmem.patch b/meta/recipes-devtools/gcc/gcc/0032-gcc-aarch64-fix-strict-align-cpymem-setmem.patch
new file mode 100644
index 0000000000..4c2d827799
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0032-gcc-aarch64-fix-strict-align-cpymem-setmem.patch
@@ -0,0 +1,45 @@
1gcc: AArch64 - Fix strict-align cpymem/setmem
2
3The cpymemdi/setmemdi implementation doesn't fully support strict alignment.
4Block the expansion if the alignment is less than 16 with STRICT_ALIGNMENT.
5Clean up the condition when to use MOPS.
6
7Upstream-Status: Backport [https://gcc.gnu.org/cgit/gcc/commit/?id=b9d16d8361a9e3a82a2f21e759e760d235d43322]
8
9Signed-off-by: Wilco Dijkstra <wilco.dijkstra@arm.com>
10Signed-off-by: Sundeep KOKKONDA <sundeep.kokkonda@windriver.com>
11---
12--- a/gcc/config/aarch64/aarch64.c 2025-05-08 20:40:10.969865898 -0700
13+++ b/gcc/config/aarch64/aarch64.c 2025-05-13 23:11:07.006796627 -0700
14@@ -23621,14 +23621,15 @@
15 int mode_bits;
16 rtx dst = operands[0];
17 rtx src = operands[1];
18+ unsigned align = UINTVAL (operands[3]);
19 rtx base;
20 machine_mode cur_mode = BLKmode;
21
22 /* Only expand fixed-size copies. */
23- if (!CONST_INT_P (operands[2]))
24+ if (!CONST_INT_P (operands[2]) || (STRICT_ALIGNMENT && align < 16))
25 return false;
26
27- unsigned HOST_WIDE_INT size = INTVAL (operands[2]);
28+ unsigned HOST_WIDE_INT size = UINTVAL (operands[2]);
29
30 /* Inline up to 256 bytes when optimizing for speed. */
31 unsigned HOST_WIDE_INT max_copy_size = 256;
32@@ -23750,11 +23751,12 @@
33 unsigned HOST_WIDE_INT len;
34 rtx dst = operands[0];
35 rtx val = operands[2], src;
36+ unsigned align = UINTVAL (operands[3]);
37 rtx base;
38 machine_mode cur_mode = BLKmode, next_mode;
39
40 /* We can't do anything smart if the amount to copy is not constant. */
41- if (!CONST_INT_P (operands[1]))
42+ if (!CONST_INT_P (operands[1]) || (STRICT_ALIGNMENT && align < 16))
43 return false;
44
45 bool speed_p = !optimize_function_for_size_p (cfun);