aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRamana Radhakrishnan <ramana@gcc.gnu.org>2015-10-09 10:58:06 +0000
committerRamana Radhakrishnan <ramana@gcc.gnu.org>2015-10-09 10:58:06 +0000
commitf869c12f4c930a233b02e31843d7a255d50ce5d1 (patch)
tree28e427e367439d44f5e2009524bd7c9f75a8d3b0 /gcc
parenta46b23e136f56e1bb44065d260b49c24b656bd8b (diff)
downloadgcc-f869c12f4c930a233b02e31843d7a255d50ce5d1.zip
gcc-f869c12f4c930a233b02e31843d7a255d50ce5d1.tar.gz
gcc-f869c12f4c930a233b02e31843d7a255d50ce5d1.tar.bz2
[PATCH PR target/67366 2/2] [gimple-fold.c] Support movmisalign optabs in gimple-fold.c
This patch by Richard allows for movmisalign optabs to be supported in gimple-fold.c. This caused a bit of pain in the testsuite with strlenopt-8.c in conjunction with the ARM support for movmisalign_optabs as the test was coded up to do different things depending on whether the target supported misaligned access or not. However now with unaligned access being allowed for different levels of the architecture in the arm backend, the concept of the helper function non_strict_align mapping identically to the definition of STRICT_ALIGNMENT disappears. Adjusted thusly for ARM. The testsuite/lib changes were tested with an arm-none-eabi multilib that included architecture variants that did not support unaligned access and architecture variants that did. The testing matrix for this patch was: 1. x86_64 bootstrap and regression test - no regressions. 2. armhf bootstrap and regression test - no regressions. 3. arm-none-eabi cross build and regression test for {-marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp} {-mthumb/-march=armv8-a/-mfpu=crypto-neon-fp-armv8/-mfloat-abi=hard} {-marm/-mcpu=arm7tdmi/-mfloat-abi=soft} {-mthumb/-mcpu=arm7tdmi/-mfloat-abi=soft} with no regressions. Ok to apply ? 2015-10-09 Richard Biener <rguenth@suse.de> PR target/67366 * gimple-fold.c (optabs-query.h): Include (gimple_fold_builtin_memory_op): Allow unaligned stores when movmisalign_optabs are available. 2015-10-09 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> PR target/67366 * lib/target-supports.exp (check_effective_target_non_strict_align): Adjust for arm*-*-*. * gcc.target/arm/pr67366.c: New test. From-SVN: r228644
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-fold.c11
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/arm/pr67366.c14
-rw-r--r--gcc/testsuite/lib/target-supports.exp9
5 files changed, 46 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8f096c7..514bb31 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-09 Richard Biener <rguenth@suse.de>
+
+ PR target/67366
+ * gimple-fold.c (optabs-query.h): Include
+ (gimple_fold_builtin_memory_op): Allow unaligned stores
+ when movmisalign_optabs are available.
+
2015-10-09 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR target/67366
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index ee2a320..17a23d6 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -63,6 +63,8 @@ along with GCC; see the file COPYING3. If not see
#include "tree-eh.h"
#include "gimple-match.h"
#include "gomp-constants.h"
+#include "optabs-query.h"
+
/* Return true when DECL can be referenced from current unit.
FROM_DECL (if non-null) specify constructor of variable DECL was taken from.
@@ -709,7 +711,9 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
/* If the destination pointer is not aligned we must be able
to emit an unaligned store. */
&& (dest_align >= GET_MODE_ALIGNMENT (TYPE_MODE (type))
- || !SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), dest_align)))
+ || !SLOW_UNALIGNED_ACCESS (TYPE_MODE (type), dest_align)
+ || (optab_handler (movmisalign_optab, TYPE_MODE (type))
+ != CODE_FOR_nothing)))
{
tree srctype = type;
tree desttype = type;
@@ -721,7 +725,10 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
srcmem = tem;
else if (src_align < GET_MODE_ALIGNMENT (TYPE_MODE (type))
&& SLOW_UNALIGNED_ACCESS (TYPE_MODE (type),
- src_align))
+ src_align)
+ && (optab_handler (movmisalign_optab,
+ TYPE_MODE (type))
+ == CODE_FOR_nothing))
srcmem = NULL_TREE;
if (srcmem)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6ce8fab..d7eba15 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-09 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
+
+ PR target/67366
+ * lib/target-supports.exp (check_effective_target_non_strict_align):
+ Adjust for arm*-*-*.
+ * gcc.target/arm/pr67366.c: New test.
+
2015-10-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/67891
diff --git a/gcc/testsuite/gcc.target/arm/pr67366.c b/gcc/testsuite/gcc.target/arm/pr67366.c
new file mode 100644
index 0000000..1e8b672
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr67366.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_unaligned } */
+/* { dg-options "-O2" } */
+
+typedef unsigned int u32;
+u32
+read32 (const void* ptr)
+{
+ u32 v;
+ __builtin_memcpy (&v, ptr, sizeof(v));
+ return v;
+}
+
+/* { dg-final { scan-assembler "@ unaligned" } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 9057a27..4d5b0a3d 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6262,6 +6262,15 @@ proc check_vect_support_and_set_flags { } {
# Return 1 if the target does *not* require strict alignment.
proc check_effective_target_non_strict_align {} {
+
+ # On ARM, the default is to use STRICT_ALIGNMENT, but there
+ # are interfaces defined for misaligned access and thus
+ # depending on the architecture levels unaligned access is
+ # available.
+ if [istarget "arm*-*-*"] {
+ return [check_effective_target_arm_unaligned]
+ }
+
return [check_no_compiler_messages non_strict_align assembly {
char *y;
typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;