From 15ddafc65e50d8198e22af9d6c741ac8db4017fd Mon Sep 17 00:00:00 2001 From: yroux Date: Tue, 26 Aug 2014 12:11:06 +0000 Subject: [PATCH] 2014-08-26 Yvan Roux Backport from trunk r213379. 2014-07-31 James Greenhalgh * config/aarch64/aarch64-builtins.c (aarch64_gimple_fold_builtin): Don't fold reduction operations for BYTES_BIG_ENDIAN. git-svn-id: svn://gcc.gnu.org/svn/gcc/branches/linaro/gcc-4_9-branch@214504 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.linaro | 9 +++++++++ gcc/config/aarch64/aarch64-builtins.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gcc/ChangeLog.linaro b/gcc/ChangeLog.linaro index 90e1289..ff183f2 100644 --- a/gcc/ChangeLog.linaro +++ b/gcc/ChangeLog.linaro @@ -1,5 +1,14 @@ 2014-08-26 Yvan Roux + Backport from trunk r213379. + 2014-07-31 James Greenhalgh + + * config/aarch64/aarch64-builtins.c + (aarch64_gimple_fold_builtin): Don't fold reduction operations for + BYTES_BIG_ENDIAN. + +2014-08-26 Yvan Roux + Backport from trunk r213378. 2014-07-31 James Greenhalgh diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index a94ef52..d67a6e3 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -1380,6 +1380,20 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi) tree call = gimple_call_fn (stmt); tree fndecl; gimple new_stmt = NULL; + + /* The operations folded below are reduction operations. These are + defined to leave their result in the 0'th element (from the perspective + of GCC). The architectural instruction we are folding will leave the + result in the 0'th element (from the perspective of the architecture). + For big-endian systems, these perspectives are not aligned. + + It is therefore wrong to perform this fold on big-endian. There + are some tricks we could play with shuffling, but the mid-end is + inconsistent in the way it treats reduction operations, so we will + end up in difficulty. Until we fix the ambiguity - just bail out. */ + if (BYTES_BIG_ENDIAN) + return false; + if (call) { fndecl = gimple_call_fndecl (stmt); -- 2.7.4